r13 cse Os Lab Manual
Short Description
Lab manual...
Description
OPERATING SYSTEMS LAB MANUAL
III-I R-13
VSM COLLEGE OF ENGINEERING
OPERATING SYSTEMS LAB MANUAL INDEX 1.
2. 3. 4.
5. 6.
7. 8. 9.
10.
Simulate the following CPU scheduling algorithms i. Round Robin ii. SJF iii. FCFS iv. Priority Loading executable programs into memory and execute system call implementation – read(),write(), open() and close() Multiprogramming-Memory management implementation of fork(),wait(),exec() & exit() system calls Simulate all file allocation strategies i. Sequential ii. Indexed iii. Linked Simulate MVT and MFT Simulate all File Organization Techniques i. Single level directory ii. Two level iii. Hierarchical iv. DAG Simulate Bankers algorithm for deadlock avoidance Simulate Bankers Algorithm for Deadlock prevention Simulate all page replacement algorithms i. FIFO ii. LRU iii. LFU Etc. … Simulate Paging Technique of memory management.
1
OPERATING SYSTEMS LAB MANUAL
III-I R-13
VSM COLLEGE OF ENGINEERING
1) Simulate the following CPU scheduling algorithms a) b) c) d)
FCFS SJF Priority Round Robin
Description: FCFS (first-come-first-serve) Scheduling First-come, First served is simplest scheduling algorithm Ready queue is a FIFO queue: Longest waiting process at the front of queue New ready processes join the rear Non-preemptive: executes until voluntarily gives up CPU finished or waits for some event Problem: CPU bound process may require a long CPU burst Other processes, with very short CPU bursts, wait in queue reduces CPU and I/O device utilization
SJF (shortest-job-first) Scheduling Assume the next burst time of each process is known SJF selects process which has the shortest burst time Optimal algorithm because it has the shortest average waiting time Impossible to know in advance OS knows the past burst times- make a prediction using an average Non-preemptive Or preemptive Shortest remaining time first Interrupts running process if a new process enters the queue New process must have shorter burst than remaining time
Round Robin Scheduling Similar to FCFS, but preemption to switch between processes Time quantum(time slice) is a small unit of time (10 to 100 ms) Process is executed on the CPU for at most one time quantum Implemented by using the ready queue as a circular queue Head process gets the CPU Uses less than a time quantum implies gives up the CPU voluntary Uses full time quantum implies timer will cause an interrupt
Context switch will be executed Process will be put at the tail of queue Priority Scheduling Assume a priority is associated with each process 2
OPERATING SYSTEMS LAB MANUAL
III-I R-13
VSM COLLEGE OF ENGINEERING
Assume all processes arrive at the same time Select highest priority process from the ready queue Let T be the next CPU burst of a process SJF is a special case of priority scheduling Equal-priority processes are scheduled in FCFS order PRIORITY can be preemptive or Non-preemptive Priorities can be defined internally Memory requirements, number of open files, burst times a) FCFS: AIM: A program to simulate the FCFS CPU scheduling algorithm
PROGRAM:
#include #include struct process { int at,ts,st,ft,ta; float nta; }; main() { struct process p[20]; int n,i,j; float tamean=0,ntamean=0; clrscr(); printf("\nEnter Number of Processes:: "); scanf("%d",&n); for(i=0;ix,root->link[i]->y); } if(root->ftype==1) bar3d(root->x-20, root->y-10,root->x+20,root->y+10,0,0); else fillellipse(root->x,root->y,20,20); outtextxy(root->x,root->y,root->name); for(i=0;inc;i++) { display(root->link[i]); } } }
7. Simulate Bankers algorithm for deadlock avoidance Aim: To simulate banker’s algorithm for deadlock avoidance Description: Deadlock Definition A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause (including itself).
Waiting for an event could be: • •
waiting for access to a critical section waiting for a resource Note that it is usually a non-preemptable (resource). Preemptable resources can be yanked away and given to another.
• • • •
• • • •
Conditions for Deadlock Mutual exclusion: resources cannot be shared. Hold and wait: processes request resources incrementally, and hold on to what they've got. No preemption : resources cannot be forcibly taken from processes. Circular wait: circular chain of waiting, in which each process is waiting for a resource held by the next process in the chain. Strategies for dealing with Deadlock ignore the problem altogether detection and recovery avoidance by careful resource allocation prevention by structurally negating one of the four necessary conditions. Deadlock Avoidance Avoid actions that may lead to a deadlock. Think of it as a state machine moving from one state to another as each instruction is executed.
Safe State Safe state is one where
It is not a deadlocked state
BANKERS ALGORITHM FOR DEADLOCK AVOIDANCE #include #include main() { int a[10][10],c[10][10],r[10],av[10],ca[10][10],i,j,k,n,m,temp=0,tem,ch; clrscr();
printf("enter no processes"); scanf("%d",&m); printf("enter no of resources"); scanf("%d",&n); printf("\nenter claim\n"); for(i=0;i
View more...
Comments