Professional Documents
Culture Documents
Systemcalls and Process
Systemcalls and Process
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communications
• wait()
• In some systems, a process needs to wait for another process to complete its
execution. This type of situation occurs when a parent process creates a child
process, and the execution of the parent process remains suspended until its child
process executes
• fork()
• Processes use this system call to create processes that are a copy of themselves. With
the help of this system Call parent process creates a child process, and the execution
of the parent process will be suspended till the child process executes.
• exec()
• This system call runs when an executable file in the context of an already running process
that replaces the older executable file. However, the original process identifier remains as a
new process is not built, but stack, data, head, data, etc. are replaced by the new process.
• kill():
• The kill() system call is used by OS to send a termination signal to a process that urges the
process to exit. However, a kill system call does not necessarily mean killing the process and
can have various meanings.
New
Ready
Running
Waiting
Blocked
Terminated
• The text section comprises the compiled program code, read in from non-volatile storage
when the program is launched.
• The data section stores global and static variables, allocated and initialized prior to executing
main.
• The heap is used for dynamic memory allocation, and is managed via calls to new, delete,
malloc, free, etc.
• .
• The stack is used for local variables. Space on the stack is reserved for local variables when
they are declared ( at function entrance or elsewhere, depending on the language ), and the
space is freed up when the variables go out of scope. Note that the stack is also used for
function return values, and the exact mechanisms of stack management may be language
specific.
• Note that the stack and the heap start at opposite ends of the process's free space and grow
towards each other. If they should ever meet, then either a stack overflow error will occur, or
else a call to new or malloc will fail due to insufficient memory available
• A process migrates between various scheduling queues throughtout its lifetime. The process
of selecting processes from these queues is carried out by a scheduler
This is also known as CPU Scheduler and runs very frequently. The
primary aim of this scheduler is to enhance CPU performance and
increase process execution rate.
Medium Term Scheduler :This scheduler removes the processes from memory (and
from active contention for the CPU), and thus reduces the degree of
multiprogramming. At some later time, the process can be reintroduced into memory
and its execution van be continued where it left off. This scheme is called swapping.
The process is swapped out, and is later swapped in, by the medium term scheduler.
• A dispatcher is a special program which comes into play after the scheduler. When
the scheduler completes its job of selecting a process, it is the dispatcher which takes
that process to the desired state/queue. The dispatcher is the module that gives a
process control over the CPU after it has been selected by the short-term scheduler.
This function involves the following:
• Switching context
• Switching to user mode
• Jumping to the proper location in the user program to restart that program
–
There are 4 processes in the ready queue, P1, P2, P3, P4; Their arrival times are t0, t1,
t2, t3 respectively. A First in First out (FIFO) scheduling algorithm is used. Because
P1 arrived first, the scheduler will decide it is the first process that should be executed,
and the dispatcher will remove P1 from the ready queue and give it to the CPU. The
scheduler will then determine P2 to be the next process that should be executed, so
when the dispatcher returns to the queue for a new process, it will take P2 and give it
to the CPU. This continues in the same way for P3, and then P4
• CPU utilization: CPU utilization is the main task in which the operating system needs to
make sure that CPU remains as busy as possible. It can range from 0 to 100 percent.
However, for the RTOS, it can be range from 40 percent for low-level and 90 percent for the
high-level system.
• Throughput: The number of processes that finish their execution per unit time is known
Throughput. So, when the CPU is busy executing the process, at that time, work is being
done, and the work completed per unit time is called Throughput.
• Minimize:
• Waiting time: Waiting time is an amount that specific process needs to wait in the
ready queue.
• Response time: It is an amount to time in which the request was submitted until the
first response is produced.
• Turnaround Time: Turnaround time is an amount of time to execute a specific
process. It is the calculation of the total time spent waiting to get into the memory,
waiting in the queue and, executing on the CPU. The period between the time of
process submission to the completion time is the turnaround time.
First Come First Serve is the full form of FCFS. It is the easiest and most
simple CPU scheduling algorithm. In this type of algorithm, the process
which requests the CPU gets the CPU allocation first. This scheduling
method can be managed with a FIFO queue.