OS Front
OS Front
Syllabus
m
Operating Systems _Btech2019_PartTime_Semseter2 22
1.1 Processes ,Process states 1.3 System Calls and Types
o
.c
○ Complex Algorithms: The algorithms are very complex and difficult ● What is a Process?
● What is System Call in Operating Systems?
es
for the designer to write on. ○ Process is the execution of a program that performs the actions specified in
that program.
○ Device driver and interrupt signals: It needs specific device drivers and ○ A system call is a mechanism that provides the interface between a
○ It can be defined as an execution unit where a program runs.
ot
interrupts signals to respond earliest to interrupts. ○ The OS helps you to create, schedule, and terminate the processes which are2
process and the operating system.
used by the CPU. ○ It is a programmatic method in which a computer program requests a
n
○ Thread Priority: It is not good to set thread priority as these systems
○ A process created by the main process is called a child process. service from the kernel of the OS.
la
are very less prone to switching tasks.
Data operations
○ ○Process Section: Contains
can bethe global
easily variable. with the help of PCB(Process
controlled ○ System call offers the services of the operating system to the user
MultiProcessing System HeapBlock).
○Control Section: Dynamically allocated memory to process during its run time.
ra
programs via API (Application Programming Interface).
○ ○YouStack: The stack
can consider it ascontains
the braintheof temporary
the process,data, such
which as function
contains all theparameters,
crucial
○ System calls are the only entry points for the kernel system.
ke
returns addresses,
information related toand local variables.
processing like process id, priority, state, CPU registers, Operating Systems _Btech2019_PartTime_Semseter2 6
etc. ● How Does System Call Work?
Asymmetric Multiprocessing Symmetric Multiprocessing ● Process
○ What states
does a process look like in memory?
○ ○ When a process executes, it passes through different states.
○ Step 1) The processes executed in the user mode till the time a system
In asymmetric multiprocessing, the In symmetric multiprocessing, all the Step 3) it.
call○ interrupts Once system call execution is over, control returns to the user
○ These stages may differ in different operating systems, and the names ofOperating these Systems _Btech2019_PartTime_Semseter2 6
processors are not treated equally. processors are treated equally.
states are also not standardized. ○ Step 2)mode., After that, the system call is executed in the kernel-mode on a
Tasks of the operating system are done by Tasks of the operating system are done ○ A process state is a condition of the process at a specific instant of time. ○ Step
priority 4) The execution of user processes resumed in Kernel mode.
basis.
the master processor. individual processor ○ It also defines the current position of the process.
○ Step 3) Once system call execution is over, control returns to the user
○
No Communication between Processors as All processors communicate with another mode.,
they are controlled by the master processor. processor by a shared memory.
○ Step 4) The execution of user processes resumed in Kernel mode.
In asymmetric multiprocessing, processes In symmetric multiprocessing, the process
m
are master-slave. is taken from the ready queue.
●
o
Asymmetric multiprocessing systems are Symmetric multiprocessing systems are ○ Text Section: A Process, sometimes known as the Text Section, also includes
cheaper. costlier.
.c
the current activity represented by the value of the Program Counter.
Asymmetric multiprocessing systems are Symmetric multiprocessing systems are
es
easier to design complex to design
For More Study Materials : [Link]
ot
● Advantages of Multiprocessor Systems
● More reliable Systems
n
○
○ In a multiprocessor system, even if one processor fails, the system will ○ New :
la
not halt.
■ A program which is going to be picked up by the OS into the main
○ This ability to continue working despite hardware failure is known as
ra
graceful degradation. memory is called a new process.
○ For example: If there are 5 processors in a multiprocessor system and ○ Ready :
ke
■ Whenever a process is created, it directly enters in the ready state, in ● Why do you need System Calls in OS?
one of them fails, then also 4 processors are still working.
○ So the system only becomes slower and does not ground to a halt. which it waits for the CPU to be assigned. ○ Reading and writing from files demand system calls.
■ The OS picks the new processes from the secondary memory and puts
○ If a file system wants to create or delete files, system calls are required.
all of them in the main memory.
● Enhanced Throughput
■ The processes which are ready for the execution and reside in the main● Why do you○ System calls are
need System used
Calls infor
OS?the creation and management of new processes.
○ If multiple processors are working in tandem, then the throughput of ○ Network connections need system calls for sending and receiving packets.
memory are called ready state processes. ○ Reading and writing from files demand system calls.
the system
increases i.e. number of processes getting executed per unit
Operating Systems _Btech2019_PartTime_Semseter2 10 ■ There can be many processes present in the ready state. ●○ How Access
○ Does to hardware
System Call devices like scanner, printer, need a system call.
14 If a file system wants to Work?
create or delete files, system calls are required.
○ Run :
■ One of the processes from the ready state will be chosen by the OS ○ System○ Stepcalls1)
areThe
used for the creation
processes executedand management
in the user modeoftillnew
the processes.
time a system
● Layered structure: depending upon the scheduling algorithm. ○ Network connections
call need system calls for sending and receiving packets.
interrupts it.
Types
●○ HowAccess of to
many System
times calls
will
hardware ‘Forked’ like
get printed byprinter,
the below code and justify
call. your
○ An OS can be broken into pieces and retain much more control on the system. ■
■ Hence, if we have only one CPU in our system, the number of running
Long Term Scheduler ○ Step 2) Afterdevices scanner,
that, the system call is needin
executed a the
system
kernel-mode on a
processes for a particular time will always be one. answer.
○ In this structure the OS is broken into a number of layers (levels). priority basis.
● Long■ term
If wescheduler runs less
have n processors frequently.
in the system then we can have n processes int main()
○ The bottom layer (layer 0) is the hardware and the topmost layer (layer N) is
● Long Term
runningSchedulers decide which program must get into the
simultaneously. {
the user interface. ● Types fork();
of System calls
○ These layers are so designed that each layer uses the functions of the lower job queue. fork();
level layers only. ● From the job queue, the Job Processor selects processes and printf("Forked\n");
○ This simplifies the debugging process as if lower level layers are debugged return 0;
loads Study
For More them into the memory
Materials for execution.
: [Link]
and an error occurs during debugging then the error must be on that layer only }
as the lower level layers have already been debugged.
● Primary aim of the Job Scheduler is to maintain a good degree
○ The main disadvantage of this structure is that at each layer, the data needs to of Multiprogramming.
be modified and passed on which adds overhead to the system. ● An optimal degree of Multiprogramming means the average The code will print "Forked" eight times. Here's why:
○ Moreover careful planning of the layers is necessary as a layer can use only
Operating Systems _Btech2019_PartTime_Semseter2 11 rate of process creation is equal to the average departure rate of
lower level layers. When the first fork() call is made, the process creates a child process, which
processes from the execution memory.
○ UNIX is an example of this structure. then executes the same code as the parent process after the fork() call. So, after
○
■ Short Term Scheduler the first fork(), there are two processes running the same code.
● Micro-kernel:
● This is also known as CPU Scheduler and runs very frequently.
○ This structure designs the operating system by removing all non-essential
● The primary aim of this scheduler is to enhance CPU When the second fork() call is made, each of the two processes created by the
components from the kernel and implementing them as system and user first fork() call creates a child process, resulting in a total of four processes
performance and increase process execution rate.
m
● This scheduler removes the processes from memory (and from Therefore, after the second fork(), there are four processes running the code,
space and does not require the kernel to be modified. each of which prints "Forked". Hence, "Forked" will be printed a total of eight
○ Thus it is more secure and reliable as if a service fails then the rest of the
active contention for the CPU), and thus reduces the degree of
times, once for each process that runs the code.
multiprogramming.
s.
○ Providing services in a microkernel system are expensive compared to the ● This scheme is called swapping. The process is swapped out,
normal monolithic system
no
system.
○ This increases the size of the kernel as well as the operating system. available memory, requiring memory to be freed up.
● This complete process is descripted in the below diagram:
ra
○ This is different from the microkernel system where the minimum software
○ Advantages of Layered
that is required structure:
to correctly implement an operating system is kept in the
■ Layering makes it easier to enhance the operating system as
kernel.
ke
implementation
○ The kernel provides of a layerservices
various can be changed
such aseasily without
memory affecting the
management, file
other layers.
management, process scheduling etc. using function calls.
○ This It is very
■ makes the easy to perform
execution of thedebugging
operatingand system
system verification.
quite fast as the services
○ Disadvantages
are implemented of under
Layered
the structure:
same address space.
■ In this structure the application performance is degraded as compared
to simple structure.
■ It requires careful planning for designing the layers as higher layers
use the functionalities of only the lower layers.