2. OPERATING SYSTEM
• An operating system (OS) is the program that, after being initially loaded into the
computer by a boot program, manages all of the other application programs in a
computer.
Need of Operating System:-
• The operating system (OS) manages all of the software and hardware on the computer.
• It performs basic tasks such as file, memory and process management, handling input and
output, and controlling peripheral devices such as disk drives and printers
5. PROCESS MANAGEMENT IN OS
• A Program does nothing unless its instructions are executed by a CPU. A program
in execution is called a process.
Responsibility of OS:-
1.Scheduling processes and threads on the CPUs.
2.Creating and deleting both user and system processes.
3.Suspending and resuming processes.
4.Providing mechanisms for process synchronization.
5.Providing mechanisms for process communication.
6. SCHEDULING ALGORITHMS IN OS
• 1. First Come First Serve
• 2. Round Robin
• 3. Shortest Job First
• 4. Shortest remaining time first
• 5. Priority based scheduling
• 6. Highest Response Ratio Next
7. PRIORITY SCHEDULING ALGORITHM
IN OS
• There is a priority number assigned to each process. In some systems, the lower
the number, the higher the priority.
• There are two types of priority scheduling algorithm exists:-
9. PROCESS SYNCHRONIZATION IN
OS
• The procedure involved in preserving the appropriate order of execution of
cooperative processes is known as Process Synchronization
• There are various synchronization mechanisms that are used to synchronize the
processes they are following:-
• 1.Race Condition:-
• It typically occurs when two or more threads try to read, write and possibly make the
decisions based on the memory that they are accessing concurrently.
• 2.Critical Section:-
• The regions of a program that try to access shared resources and may cause race
conditions are called critical section.
10. CRITICAL SECTION
• The critical section cannot be executed by more than one process at the same time;
operating system faces the difficulties in allowing and disallowing the processes
from entering the critical section.
• The critical section problem is used to design a set of protocols which can ensure
that the Race condition among the processes will never arise.
Synchronization mechanism is judged on the basis of four conditions:-
1.Mutual Exclusion
2.Progress
3.Bounded Waiting
4.Portability
11. PATERSON SOLUTION
• This is a software mechanism implemented at user mode. It is a busy waiting solution can be
implemented for only two processes. It uses two variables that are turn variable and interested
variable
CODE:-
1. # define N 2
2. # define TRUE 1
3. # define FALSE 0
4. int interested[N] = FALSE;
5. int turn;
6. voidEntry_Section (int process)
7. { int other; other = 1-process;
8. interested[process] = TRUE;
9. turn = process;
10. while (interested [other] =True && TURN=process); }
11. voidExit_Section (int process) {
12. interested [process] = FALSE; }
12. SEMAPHORE IN OPERATING
SYSTEMS
• Semaphore is a Hardware Solution. This Hardware solution is written or given to
critical section problem.
• The Semaphore is just a normal integer. The Semaphore cannot be negative. The
least value for a Semaphore is zero (0). The Maximum value of a Semaphore can
be anything.
The two Semaphore Operations are:
1.Wait ( )
2.Signal ( )
Advantages of Semaphore :-
• Semaphores have the very good management of resources
• They forbid several processes from entering the crucial area. They are significantly
more effective than other synchronization approaches since mutual exclusion is
made possible in this way.
13. TYPES OF SEMAPHORES
• There are two types of Semaphores.
• They are:
• 1. Binary Semaphore:-
• There are only two values of Semaphore in Binary Semaphore Concept. The two
values are 1 and 0.
• 2. Counting Semaphore:-
• There are two sets of values of Semaphore in Counting Semaphore Concept. The
two types of values are values greater than and equal to one and other type is value
equal to zero.