KEMBAR78
Unit - 1 | PDF | Process (Computing) | Operating System
0% found this document useful (0 votes)
23 views15 pages

Unit - 1

This document provides an overview of operating systems, detailing their role as intermediaries between users and computer hardware, and outlining key concepts such as processes, system calls, and operating system services. It describes the user and system perspectives on operating systems, the types of user interfaces, and the various services provided by operating systems for program execution, I/O operations, and resource management. Additionally, it covers process management, including process states, control blocks, and scheduling mechanisms.

Uploaded by

hemanthnk04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views15 pages

Unit - 1

This document provides an overview of operating systems, detailing their role as intermediaries between users and computer hardware, and outlining key concepts such as processes, system calls, and operating system services. It describes the user and system perspectives on operating systems, the types of user interfaces, and the various services provided by operating systems for program execution, I/O operations, and resource management. Additionally, it covers process management, including process states, control blocks, and scheduling mechanisms.

Uploaded by

hemanthnk04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

20CSM6701

FUNDAMENTALS OF OPERATING SYSTEMS


UNIT - 1

Introduction: What Operating Systems do


Operating-System Structures: Operating-System Services, User and Operating- System
Interface. System call-Types of Systems calls
Processes: Process Concept, Process Scheduling

Operating System:

 An operating system acts as an intermediary between the user of a computer and the
computer hardware.
 The purpose of an operating system is to provide an environment in which a user can
execute programs in a convenient and efficient manner.
 An operating system is software that manages the computer hardware. It also provides
a basis for application programs and acts as an intermediary between the computer user
and the computer hardware.
 The hardware must provide appropriate mechanisms to ensure the correct operation of
the computer system and to prevent programs from interfering with the proper operation
of the system.
Hardware:
What Operating Systems do:
A computer system can be divided roughly into four components: the hardware, the
operating system, the application programs,and a user. The hardware—the central processing
unit (CPU), the memory, and the input/output (I/O) devices—provides the basic computing
resources for the system. The application programs—such as word processors, spreadsheets,
compilers, and web browsers—define the ways in which these resources are used to solve
users’ computing problems. The operating system controls the hardware and coordinates its
use among the various application programs for the various users.
We can also view a computer system as consisting of hardware, software, and data. The
operating system provides the means for proper use of these resources in the operation of the
computer system. An operating system is similar to a government. Like a government, it
performs no useful function by itself. It simply provides an environment within which other
programs can do useful work. To understand more fully the operating system’s role, we next
explore operating systems from two viewpoints: that of the user and that of the system.

User View:
The user’s view of the computer varies according to the interface being used. Many
computer users sit with a laptop or in front of a PC consisting of a monitor, keyboard, and
mouse. Increasingly, many users interact with mobile devices such as smartphones and
tablets—devices that are replacing desktop and laptop computer systems for some users. These
devices are typically connected to networks through cellular or other wireless technologies.
The user interface for mobile computers generally features a touch screen, where the user
interacts with the system by pressing and swiping fingers across the screen rather than using a
physical keyboard and mouse. Many mobile devices also allow users to interact through a voice
recognition interface, such as Apple’s Siri. Some computers have little or no user view. For
example, embedded computers

System View:
From the computer’s point of view, the operating system is the program most intimately
involved with the hardware. In this context, we can view an operating system as a resource
allocator. A computer system has many resources that may be required to solve a problem:
CPU time, memory space, storage space, I/O devices, and so on. The operating system acts as
the manager of these resources. Facing numerous and possibly conflicting requests for
resources, the operating system must decide how to allocate them to specific programs and
users so that it can operate the computer system efficiently and fairly.
An operating system is a control program. A control program manages the execution
of user programs to prevent errors and improper use of the computer. It is especially concerned
with the operation and control of I/O devices.

Operating-System Services:
An Operating System provides an environment for the execution of programs.
It provides certain services to programs and to the users of those programs. The
specific services provided are differ from one operating system to another. One set of
operating system services provides functions that are helpful to the user.

1) User Interface
• Almost all operating systems have a user interface. This interface can take several forms
• Command Line Interface: Command Line Interface which uses text commands and a
method for entering them.
• Batch Interface: Batch Interface in which commands and directives to control those
commands are entered into files, and those are executed.
• Graphical User Interface: This interface is a window system with a pointing device
to direct I/O, choose from menus, and make selections and a keyboard to enter text.
2) Program execution
• The system must be able to load a program into memory and to run that program.
• The program must be able to end its execution, either normally or abnormally.
3) I/O operation
• A running program may require I/O, which may involve file or an I/O device.
• For efficiency and protection, users usually cannot control I/O devices directly.
Therefore, the operating system must provide a means to do I/O.
4) File System manipulation
• The file System is of particular interest obviously, programs need to read and write
files and directories.
• They also need to create and delete them by name, search for a given file, and list file
information.
• Some program includes permissions management to allow or deny access to files or
directories based on file ownership.
5) Communication
• There are many circumstances in which one process needs to exchange information
with another process.
• Such communication may occur between processes that are executing on the same
computer or between processes that are
executing on different computer systems tied together by a computer network.
• Communication may be implemented via shared memory or through message passing
6) Error Detection:
• The operating system needs to be constantly aware of possible errors.
• Error may occur in the CPU and memory hardware (such as a memory error or a
power failure), in I/O devices.
• Debugging facilities can greatly enhance the user’s and programmer’s abilities to use
the system efficiently.
7) Resource Allocation
• When there are multiple users or multiple jobs running at a same time, resources must
be allocated to each of them.
• Many different types of resources are managed by the operating system.
• Some may have special allocation code, whereas others may have much more general
request and release code.
8) Accounting
• We want to keep track of which users use how much and what kinds of computer
resources.
• This record keeping may be used for accounting so that user billed or simply for
accumulating usage statistics.
9) Protection and security
• The owners of information stored in a multiuser or networked computer system may
want to control use of that information.
• When several separate processes execute concurrently, it should not be possible for
one process to interface with the others or with the operating system itself.
• Protection involves ensuring that all access to system resources is controlled. Security
of the system from outsiders is also important.

User and Operating- System Interface:


Three interfaces allow users to interface with the operating system, those are
Command-Line interface, Graphical User Interface(GUI), and Touch-Screen Interface.

Command-Line interface:
The main function of the command interpreter is to get and execute the next user-
specified command. Many of the commands given at this level manipulate files: create, delete,
list, print, copy, execute, and so on. The various shells (C shell, Bourne-Again shell, Korn shell )
available on UNIX systems operate in this way.
These commands can be implemented in two general ways. In one approach, the
command interpreter itself contains the code to execute the command. For example, a
command to delete a file may cause the command interpreter to jump to a section of its code
that sets up the parameters and makes the appropriate system call.
An alternative approach—used by UNIX, among other operating systems —
implements most commands through system programs. In this case, the command interpreter
does not understand the command in any way; it merely uses the command to identify a file to
be loaded into memory and executed.Thus, the UNIX command to delete a file
rm file.txt
would search for a file called rm, load the file into memory, and execute it with the parameter
file.txt.

Graphical User Interface(GUI):


A second strategy for interfacing with the operating system is through a userfriendly
graphical user interface, or GUI. Here, rather than entering commands directly via a command-
line interface, users employ a mouse-based windowand-menu system characterized by a
desktop metaphor. The user moves the mouse to position its pointer on images, or icons, on
the screen (the desktop) that represent programs, files, directories, and system functions.
Depending on the mouse pointer’s location, clicking a button on the mouse can invoke a
program, select a file or directory—known as a folder—or pull down a menu that contains
commands.

Touch-Screen Interface:
Because a either a command-line interface or a mouse-and-keyboard system is
impractical for most mobile systems, smartphones and handheld tablet computers typically use
a touch-screen interface. Here, users interact by making gestures on the touch screen—for
example, pressing and swiping fingers across the screen.
System Calls:
System calls provide an interface to the services made available by an operating system.
These system calls are generally available as routines written in C and C++. Certain low-level
tasks are written in assembly-language instructions.

Below is a sequence of system calls to copy the contents of one file to another
file:
cp in.txt out.txt

System calls are mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use. Three most common APIs are
 Win32 API for Windows
 POSIX* API for POSIX-based systems (including virtually all versions of UNIX,
Linux, and Mac OS X)
 Java API for the Java virtual machine (JVM)

Another important factor in handling system calls is the run-time environment (RTE)—
the full suite of software needed to execute applications written in a given programming
language, including its compilers or interpreters as well as other software, such as libraries and
loaders.
The RTE provides a system-call interface that serves as the link to system calls made
available by the operating system. The system-call interface intercepts function calls in the API
and invokes the necessary system calls within the operating system. Typically, a number is
associated with each system call, and the system-call interface maintains a table indexed
according to these numbers. The system call interface then invokes the intended system call in
the operating system kernel and returns the status of the system call. System calls occur in
different ways, depending on the computer in use.
Types of System Calls:
System calls can be grouped roughly into six major categories: process control,
fil management, device management, information maintenance, communications,
and protection.
Process:
 A program in execution is called a process.
 A process will need certain resources such as CPU time, memory, files and I/O devices to
accomplish its task.
 These resources are allocated to the process either when it is created or while it is
executing.
 An operating system executes a variety of programs: Batch system jobs, Time shared
systems, user programs or tasks
 Generally the terms job and process are almost the same.
 Process execution must progress in sequential fashion
A process includes:
 program counter
 stack
 data section

Fig: Process in memory


 A process is a program under execution.
 It generally includes process stack, containing temporary data (such as sub routine
parameters, return addresses, temporary variables) and data section containing global
variables.
 A program is a passive entity such as the contents of files stored on a disk.
 A Process is an active entity with a program counter, specifying the next instruction to
execute and set of associated resources.

Process State:

 As a process executes, it changes state.


 The state of process is defined in part by the current activity of that process.
 Each process may be in one of the following states.

Fig: Process State Diagram


New: The process is being created.
Running: Instructions are being executed.
Waiting: The process is waiting for some event to occur (such as I/O completion or reception
of a signal).
Ready: The process is waiting to be assigned to the processor.
Terminated: The process has finished execution.
 At any point of time only one process can be running. Many processes may be ready
and waiting.\

Process Control Block:


 Each process is represented in the operating system by a process control block also
called task control block.
Information associated with each process
 Process state
 Program counter
 CPU registers
 CPU scheduling information
 Memory-management information
 Accounting information
 I/O status information

Fig: Process Control Block (PCB)


It contains many pieces of information associated with a specific process, including these:
 Process State: The state may be new, ready, running, and waiting, halted and so on…
 Program Counter: The counter indicates the address of next instruction to be executed
for this process.
 CPU Registers: The registers vary in number and type, depending on computer
architecture. They include accumulators, index registers, stack pointers and general
purpose registers plus any condition code information.
 CPU Scheduling Information: The information includes a process priority, pointers to
scheduling queues and any other scheduling parameters
 Memory Management Information : This include information such as the values of the
base and limit registers, the page tables or segment tables depending on the memory system
used by operating system
 Accounting Information: This includes the amount of CPU and real time used, time
limits, account numbers, job or process numbers and so on…
 I/O Status Information: This includes the list of I/O devices such as tape drivers allocated
to this process, list of open files and so on….

Process Scheduling:
The objective of multiprogramming is to have some process running at all times so as to
maximize CPU utilization. The objective of time sharing is to switch a CPU core among
processes so frequently that users can interact with each program while it is running. To meet
these objectives, the process scheduler selects an available process (possibly from a set of
several available processes) for program execution on a core.
Each CPU core can run one process at a time. For a system with a single CPU core,
there will never be more than one process running at a time, whereas a multicore system can
run multiple processes at one time. If there are more processes than cores, excess processes
will have to wait until a core is free and can be rescheduled. The number of processes currently
in memory is known as the degree of multiprogramming.
An I/O-bound process is one that spends more of its time doing I/O than it spends
doing computations. A CPU-bound process, in contrast, generates I/O requests infrequently,
using more of its time doing computations.
As processes enter the system, they are put into a ready queue, where they are ready
and waiting to execute on a CPU’s core This queue is generally stored as a linked list; a ready-
queue header contains pointers to the first PCB in the list, and each PCB includes a pointer
field that points to the next PCB in the ready queue.

Scheduling Queues:
A new process is initially put in the ready queue. It waits there until it is selected for
execution, or dispatched. Once the process is allocated a CPU core and is executing, one of
several events could occur:
 The process could issue an I/O request and then be placed in an I/O wait queue.
 The process could create a new child process and then be placed in a wait queue while
it awaits the child’s termination.
 The process could be removed forcibly from the core, as a result of an interrupt or
having its time slice expire, and be put back in the ready queue.
In the first two cases, the process eventually switches from the waiting state to the ready
state and is then put back in the ready queue. A process continues this cycle until it terminates,
at which time it is removed from all queues and has its PCB and resources deallocated.

 Job Queue: As processes enter the system they are put into a job queue this queue
consists of all process in the system
 Ready queue: The processes that are residing in main memory and are ready and
waiting to execute are kept a list called the ready queue. This queue is generally
stored as a linked list. A ready queue header will contain pointers to the first and last
PCB’s in the list. Each PCB has a pointer field that points to the next process in the
ready queue.
 Device Queue or Waiting Queue: A list of process waiting for a particular I/O
device is called a device queue.
Fig: Queuing diagram representation of process scheduling.

Schedulers:

 Long-term Scheduler:
 It is also known as job scheduler.
 It selects processes from this pool and loads them into memory for execution.
 It executes much less frequently; minutes may separate the creation of one new process
and the next.
 It controls the degree of multiprogramming.

 Short-term Scheduler:
 It is also known as CPU scheduler.
 It selects from among the processes that are ready to execute and allocates the CPU to
one of them.
 It must select a new process for the CPU frequently.
 It executes at least once every 100ms.Because of the short time between executions;
the short-term scheduler must be fast. If it takes 10ms to decide to execute a process
for 100ms, then 10/(100+10)=9% of the CPU is being used(Wasted) simply for the
scheduling work.

 Medium-term Scheduler:
 The medium-term scheduler temporarily removes processes from main memory and
places them in secondary memory and vice versa.
 This is referred as "swapping out" or "swapping in" / "paging out" or "paging in".
 The medium-term scheduler may decide to swap out a process which has not been
active for some time, or a process which has a low priority, or a process which is page
faulting frequently, or a process which is taking up a large amount of memory in order
to free up main memory for other processes, swapping the process back in later when
more memory is available, or when the process has been unblocked and is no longer
waiting for a resource.

Processes can be described as either:


 I/O-bound process – spends more time doing I/O than computations, many short CPU
bursts
 CPU-bound process – spends more time doing computations; few very long CPU
bursts

 Fig: Addition of medium-term scheduling to the queuing diagram

Context Switch:

 Interrupts cause the operating system to change a CPU core from its current task and to run
a kernel routine.
 Switching the CPU core to another process requires performing a state save of the current
process and a state restore of a different process. This task is known as a context switch.
 When a context switch occurs, the kernel saves the context of the old process in its PCB
and loads the saved context of the new process scheduled to run.

You might also like