objective: to learn about the various system calls. to perform the various cpu scheduling...
TRANSCRIPT
CS1255 – OPERATING
SYSTEMS LABORATORY
OBJECTIVE:• To learn about the various system calls.• To perform the various CPU scheduling
algorithms.• To understand the concept of memory
management schemes.• To know more about the semaphores and
Inter process communication.
AIM:
To understand the basic concepts of operating system.
LIST OF EXERCISES
S.NO TITLE OF THE PROGRAMS
1.a. Program using exec & wait system calls
1.b. Program using fork & exit system calls
1.c. Program using opendir & readdir system calls
1.d. Program using stat system calls
2. Program to implement I/O system call of unix operating system
3.a. Simulation of ls command
3.b. Simulation of grep command
4.a. Implementation of First Come First Serve Scheduling algorithm
4.b. Implementation of Shortest Job First Scheduling algorithm
S.NO TITLE OF THE PROGRAMS
5. Implementation of Priority & Round Robin Scheduling algorithm
6. Application using Inter Process Communication
7.Implementation of Producer – Consumer Problem using Semaphores
8.Implementation of Memory Management Scheme -I
9.Implementation of Memory Management Scheme -II
10.a.Implementation of First In First Out Page Replacement algorithm
10.b.Implementation of Best Fit algorithm
10.c.Implementation of First Fit algorithm
Hardware and Software required
• HARDWARE: Personal Computers
• SOFTWARE: Linux
SYSTEM CALLSA request to the operating system to perform some
activitySystem call is how a program requests a service
from an operating system 's kernelSystem calls provide the interface between a
process and the operating system.
EXAMPLE OF SYSTEM CALLS
getuid() //get the user IDfork() //create a child processexec() //executing a program
SCHEDULING ALGORITHMS A scheduling algorithm is the method by which
threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth).
This is usually done to load balance a system effectively or achieve a target quality of service.
SCHEDULING ALGORITHMS
First-come, first-served scheduling (FCFS) algorithm
Shortest Job First Scheduling (SJF) algorithm Non-preemptive priority Scheduling algorithm Preemptive priority Scheduling algorithm Round-Robin Scheduling algorithm Multilevel Feedback Queue Scheduling algorithm Multilevel Queue Scheduling algorithm
FCFS
Process Burst TimeP1 24 P2 3 P3 3
Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
Waiting time for P1 = 0; P2 = 24; P3 = 27Average waiting time: (0 + 24 + 27)/3 = 17
P1 P2 P3
24 27 300
SJFProcess Arrival Time Burst TimeP1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (non-preemptive)
Average waiting time = (0 + 6 + 3 + 7)/4 = 4
P1 P3 P2
73 160
P4
8 12
Process Arrival Time Burst TimeP1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4
SJF (preemptive)
Average waiting time = (9 + 1 + 0 +2)/4 = 3
P1 P3P2
42 110
P4
5 7
P2 P1
16
Priority Scheduling
A priority number (integer) is associated with each process
The CPU is allocated to the process with the highest priority (smallest integer ≡ highest priority).
1. Preemptive 2. non-preemptiveSJF is a priority scheduling where priority is the
predicted next CPU burst time.Problem ≡ Starvation – low priority processes
may never execute.Solution ≡ Aging – as time progresses increase
the priority of the process.
RR
(Quantum=20) Process Burst TimeP1 53 P2 17 P3 68 P4 24
The Gantt chart is:
Typically, higher average turnaround than SJF, but better response
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
INTER PROCESS COMMUNICATION
Inter-process communication (IPC) is a set of techniques for the exchange of data among multiple threads in one or more processes .
Processes may be running on one or more computers connected by a network.
SEMAPHORES
Semaphores provide mutual exclusion.
They are used for process sync and are used to resolve deadlock conditions.
They are used in pairs basically wait() and signal().
Commonly used semaphore is mutex()
PAGE REPLACEMENT ALGORITHMS page replacement algorithms decide which
memory pages to page out (swap out, write to disk) when a page of memory needs to be allocated.
Paging happens when a page fault occurs and a free page cannot be used to satisfy the allocation
Memory ManagementMemory-Management Unit (MMU)
SWAPPING
PAGING
Page Replacement Algorithms(FIFO)