OS CD LAB MANUAL
May 5, 2017 | Author: madirikiran | Category: N/A
Short Description
Download OS CD LAB MANUAL...
Description
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY,ANANTAPUR. III Year B.Tech. CSE -II Sem
T
P
C
0
3
2
OPERATING SYSTEMS AND COMPILER DESIGN LAB Objective : • To provide an understanding of the language translation peculiarities by designing a complete translator for a mini language. • To provide an understanding of the design aspects of operating system Recommended Systems/Software Requirements: • Intel based desktop PC with minimum of 166 MHZ or faster processor with atleast 64 MB RAM and 100 MB free disk space • C++ complier and JDK kit
Part-A (OS) 1. Simulate the following CPU scheduling algorithms a. Round Robin b. SJF c. FCFS d. Priority 2. Simulate all file allocation strategies a. Sequential b. Indexed c. Linked 3. Simulate MVT and MFT 4. Simulate all File Organization Techniques a. Single level directory b. Two level c. Hierarchical d. DAG 5. Simulate Bankers algorithm for deadlock avoidance 6. Simulate Bankers Algorithm for Deadlock prevention 7. Simulate all page replacement algorithms a. FIFO b. LRU c. LFU Etc. … 8. Simulate Paging Technique of memory management.
Part-B (CD) 1. 2. 3. 4.
Lexical Analysis Lexical Analyzer using LEX-tool Compute FIRST() and FOLLOW() functions for the given language Design predictive parser for the given language
1.Aim: Simulate the following CPU scheduling algorithms
a) Round Robin b) SJF
c) FCFS d) Priority
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 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 Priorities can be defined externally
Program:
Round Robin Scheduling Algorithm
#include #include struct process { int at,ts,st,ft,wait,ts2,ta; float nta; }p[20]; main() { int i,j,slice,n; float tamean=0,ntamean=0; clrscr(); printf("Enter Number of Processes :: "); scanf("%d",&n); for(i=0;i' || ch == '|') { count =1; } if(set==1) /* its a non-terminal production */ { for(i=0;iaAc A->b
Output: FOLLOW(s)={$} FOLLOW(A)={c}
Aim:
Design Predictive Parser for the given language
Program: /* Execute first.c and follow.c before compiling this */ #include char ter[20]; main() { FILE *fp,*fp1,*fp2; char ch,prod[20],ch1,term1[20],ch2; int i=0,set=0,j,k=0,row=2;; fp = fopen("input.txt","r"); ch = fgetc(fp); /* placing the terminals */ while( !(feof(fp)) ) { if( set==1 ) if( (ch >= 'a')&&(ch= 'a')&&(ch0)
{ term1[k] = '\0'; k--; } } if(ch=='|') { while(prod[j]!='>') prod[j--]='\0'; j++; set=2; } else if(ch=='\n') { while(j>0) prod[j--]='\0'; printf("------------------------------------------------------------------------------\n"); row++; set=1; } if(ch=='>') set=2;
} } unione(char ch) { static int i=0; int j=0; for(;j=i) { ter[j]=ch; i++; } }
Input: E->TA A->+TA|# T->FB B->*FB|# F->(E)|i Output: E (i
A +# T (i B *# F (i follow.txt E )$ A )$ T +)$ B +)$ F*+)$ + * ( ) i $ ================================================ E-> E->TA E->TA -----------------------------------------------------------------------A-> A->TA A-># A-># -----------------------------------------------------------------------T-> T->FB T->FB -----------------------------------------------------------------------B-> B-># B->*FB B-># B-># -----------------------------------------------------------------------F-> F(E) F->i
View more...
Comments