Operating Systems Laboratory Manual III YEAR I Semester B.TECH (Computer Science and Engineering) INFORMATION TECHNOLOGY Department of Computer Science and Engineering Department of Information Technology 1|Page Operating Systems Laboratory Manual III YEAR B.TECH Information (Computer ScienceTechnology and Engineering) DepartmentofofComputer InformationScience Technology Department & Engineering Date of Issue Document No: MLRIT/IT/LAB MANUAL/OS MLRIT/IT/LAB MANUAL/OS MLRIT/CSE/LAB MANUAL/OS VERSION 1.1.4 Date of Revision Compiled by Ms. Naga Kalyani.A Mr. Madan Reddy Mr. Dayakar Verified by Mr.G.Kiran Kumar HOD (CSE) Authorized by HOD(CSE) 2|Page PREFACE The course provides an overview of the organization of operating systems for generalpurpose computers. Students will be exposed to several new aspects of programming including: process scheduling, process synchronization, multi-process computation, deadlock avoidance, file system organization, and security. Students will get knowledge about the concepts in Operating Systems and techniques used in their implementation. This Course presents different aspects of operating systems such as; memory management, process scheduling, management of devices, IO management, multi-tasking, multi-thread programming, file systems and inter-process communication techniques. HOD (CSE) Principal 3|Page Steps in Program Development Program development is a multi step process. The steps are 1) Understand the problem 2) Develop a solution 3) Write the program and test it. 1. Understand the problem: When you are assigned to develop a program for solving a problem, you are given the programming requirements. Study these requirements carefully resolve all doubts and ensure that you have understood it fully as per the user requirements. 2. Develop a solution: Once you have understood the problem, you have to develop the solution in terms of some programming language. The tools that help in this are: a) Algorithm / Pseudo code b) Flowchart c) Programming Language, like C, C++ etc., d) Test cases a) Algorithm Definition: A method of representing the step-by-step logical procedure for solving a problem in natural language (like English, etc.) is called as an Algorithm. Algorithm can also be defined as an ordered sequence of well-defined and effective operations that, when executed, will always produce a result and eventually terminate in a finite amount of time. On the whole an algorithm is a recipe for finding a right answer to a problem by breaking it down into simple steps. Properties an Algorithm should possess: a. Generality: The algorithm must be complete in itself so that it can also be used to solve all problems of a specific type for given input data. b. Input / Output: Each algorithm can take zero, one or more input data and must produce one or more output values. c. Optimization: Unnecessary steps should be eliminated so as to make the algorithm to terminate in finite number of steps. d. Effectiveness: Each step must be effective in the sense that it should be primitive (easily convertible into program statement) and can be performed exactly in a finite amount of time. e. Definiteness: Each step of the algorithm, should be precisely and unambiguously stated. 4|Page b) Flowchart: Definition: It is a diagrammatic representation of an algorithm. It is constructed using different types of symbols. Standard symbols used in drawing flowcharts: Terminal Start/stop/begin/end Oval Making data available for processing(input) or recording of the processed information(output) Show data output in the form of document Parallelogram Input/output Document Printout Rectangle Process Diamond Decision Any processing to be performed. A process changes or moves data. An assignment operation Decision or switching type of operation Circle Connector Used to connect different parts of flowchart Arrow Flow Joins two symbols and also represents flow of execution Annotation Descriptive comments explanation Bracket with broken line Double sided rectangle Predefined process or Modules or subroutines specified elsewhere Programming and Testing: A computer program is the sequence of instructions written in a computer language according to the algorithm and computer follows these in carrying out its computations. The process of writing a program is called programming. Steps involved in Computer Programming: Problem Understanding Problem Definition Program writing Error analysis Validation & Verification Documentation & Maintenance 5|Page OPERATING SYSTEMS LAB SYLLABUS OBJECTIVE To use Linux operating System for study of operating system concepts. To write the code to implement and modify various concepts in operating system in Linux. 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 Dead Lock Avoidance 6. Simulate Bankers Algorithm for Dead Lock Prevention 7. Simulate all page replacement algorithms a) FIFO b) LRU c) LFU Etc. … 8. Simulate Paging Technique of memory management. OUTCOMES: The course objectives ensure the development of students applied skills in operating systems related areas. Students will gain knowledge in writing software routines modules or implementing various concepts of operating systems. 6|Page LAB INSTRUCTIONS 1. Students should report to the concerned lab as per the time table. 2. Students who turn up late to the labs will in no case be permitted to do the program schedule for the day. 3. After completion of the program, certification of the concerned staff in-charge in the observation book is necessary. 4. Student should bring a notebook of 100 pages and should enter the readings /observations into the notebook while performing the experiment. 5. The record of observations along with the detailed experimental procedure of the experiment in the immediate last session should be submitted and certified staff member in-charge. 6. Not more than 3-students in a group are permitted to perform the experiment on the set. 7. The group-wise division made in the beginning should be adhered to and no mix up of students among different groups will be permitted. 8. The components required pertaining to the experiment should be collected from stores incharge after duly filling in the requisition form. 9. When the experiment is completed, should disconnect the setup made by them, and should return all the components/instruments taken for the purpose. 10. Any damage of the equipment or burn-out components will be viewed seriously either by putting penalty or by dismissing the total group of students from the lab for the semester/year. 7|Page TABLE CONTENT(As per JNTUH Syllabus) S.No Week No Name of the program Page No Simulate the following cpu scheduling algorithms: a) FCFS b) SJF 1. c) Round Robin d) priority 2. Simulate the file allocation strategies: a) Sequential 3. b) Indexed 4. c) Linked 5. Simulate MVT and MFT 6. Simulate all file Organization Techniques a) Single level 7. b) Two Level 8. c) Hierarchical 9. d) DAG 10. Simulate Bankers Algorithm for Deadlock Avoidance 11. Simulate Bankers algorithm for Deadlock Prevention 12. Simulate all page replacement Algorithms a)FIFO 13. b) LRU 14. c) LFU 15. Simulate Paging Technique of memory management. 8|Page OPERATING SYSTEMS EXPERIMENT : 1 NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms a) FCFS b) SJF c) Round Robin d) Priority AIM: Using CPU scheduling algorithms find the min & max waiting time. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: CPU SCHEDULING Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait CPU burst distribution a) First-Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: 9|Page 0 30 24 27 Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the processname, Burst times , arrival times of processes 5. calculate the waiting time of each process wt[i+1]=bt[i]+wt[i] 6. calculate the turnaround time of each process tt[i+1]=tt[i]+bt[i+1] 7. Calculate the average waiting time and average turnaround time. 8. Display the values 9. Stop TEST CASES: 10 | P a g e Problem Statements: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS FOR WEEK1 P1: Simulate FCFS scheduling without arrival times to display average waiting time along with process id. TEST CASES: P2: Simulate FCFS scheduling without arrival times to calculate average turnaround time. TEST CASES: P3: Simulate FCFS scheduling with arrival times to calculate average waiting time. TEST CASES: 11 | P a g e P4: Simulate FCFS scheduling with arrival times to calculate average turnaround time. TEST CASES: P5: Simulate FCFS t scheduling to display the start time and finish time of each process(without arrival time) TEST CASES: P6: Simulate FCFS scheduling to display the start time and finish time of each process (with arrival time). TEST CASES: 12 | P a g e P7: Simulate FCFS scheduling to display gantt chart with arrival time. TEST CASES: P8: Simulate FCFS scheduling to display Gantt chart for processes without arrival times. TEST CASES: 13 | P a g e P9: Simulate FCFS scheduling to display gantt chart and average waiting time with arrival time. TEST CASES: P10: Simulate FCFS scheduling to display gantt chart and average Turnaround time with arrival time. TEST CASES: VIVA QUESTIONS 14 | P a g e 1. What is First-Come-First-Served (FCFS) Scheduling? 2. Why CPU scheduling is required? 3. Which technique was introduced because a single job could not keep both the CPU and the I/O devices busy? 1) Time-sharing 2) SPOOLing 3) Preemptive scheduling 4) Multiprogramming 4. CPU performance is measured through ________. 1) Throughput 2) MHz 3) Flaps 4) None of the above 5. Which of the following is a criterion to evaluate a scheduling algorithm? 1 CPU Utilization: Keep CPU utilization as high as possible. 2 Throughput: number of processes completed per unit time. 3 Waiting Time: Amount of time spent ready to run but not running. 4 All of the above EXPERIMENT : 1b) NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms b) SJF AIM: Using CPU scheduling algorithms find the min & max waiting time. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: Example of Non Preemptive SJF Process Arrival Time Burst Time P1 0.0 7 P2 2.0 4 P3 4.0 1 P4 3.0 4 P1 P3 P2 0 7 8 P4 12 16 Example of Preemptive SJF Process P1 Arrival Time 0.0 Burst Time 7 15 | P a g e P2 2.0 4 P3 4.0 1 P4 3.0 4 P1 P2 0 2 P3 4 P2 5 P4 7 P1 11 16 Average waiting time = (9 + 1 + 0 +2)/4 = 3 ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the Burst times of processes 5. sort the Burst times in ascending order and process with shortest burst time is first executed. 6. calculate the waiting time of each process wt[i+1]=bt[i]+wt[i] 7. calculate the turnaround time of each process tt[i+1]=tt[i]+bt[i+1] 8. Calculate the average waiting time and average turnaround time. 9. Display the values 10. Stop PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS FOR WEEK2 P1: Simulate Shortest job first scheduling without arrival times to calculate average waiting time. TEST CASES: 16 | P a g e P2: Simulate Shortest job first scheduling without arrival times to calculate average turnaround time. TEST CASES: P3: Simulate Shortest job first scheduling with arrival times to calculate average waiting time. TEST CASES: 17 | P a g e P4: Simulate Shortest job first scheduling with arrival times to calculate average turnaround time. TEST CASES: P5: Simulate Shortest job first scheduling to display only the start time and finish time of each process.(without arrival time). TEST CASES: Enter Enter Enter Enter Enter Enter Enter Enter the number of processes:3 the name, burst time for processes the name of the process:p1 Burst time for process P1 in ms:10 the name of the process:p2 Burst time for process P2 in ms:5 the name of the process:p3 Burst time for process P3 in ms:3 Process BT ST FT -------------------------------------p3 3ms 0ms 3ms p2 5ms 3ms 8ms p1 10ms 8ms 18ms P6: Simulate Shortest job first scheduling to display the start time and finish time of each process and their average waiting time.(without arrival time). TEST CASES: Enter Enter Enter Enter the number of processes:3 the name, burst time for processes the name of the process:p1 Burst time for process P1 in ms:10 18 | P a g e Enter Enter Enter Enter the name of the process:p2 Burst time for process P2 in ms:5 the name of the process:p3 Burst time for process P3 in ms:3 Process BT ST FT -------------------------------------p3 3ms 0ms 3ms p2 5ms 3ms 8ms p1 10ms 8ms 18ms Average waiting time=3.33ms P7: Simulate Shortest job first scheduling to display the start time and finish time of each process and their average turnaround time.(without arrival time). TEST CASES: Enter Enter Enter Enter Enter Enter Enter Enter the number of processes:3 the name, burst time for processes the name of the process:p1 Burst time for process P1 in ms:10 the name of the process:p2 Burst time for process P2 in ms:5 the name of the process:p3 Burst time for process P3 in ms:3 Process BT ST FT -------------------------------------p3 3ms 0ms 3ms p2 5ms 3ms 8ms p1 10ms 8ms 18ms Average turnaround time=6.6ms P8: Simulate Shortest job first scheduling to calculate average waiting time by defining a separate sjf function . TEST CASES: Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter the number of processes:3 the name, burst time & arrival time for processes the name of the process:p1 Arrival time for process P1 in ms:0 Burst time for process P1 in ms:10 the name of the process:p2 Arrival time for process P2 in ms:0 Burst time for process P2 in ms:5 the name of the process:p3 Arrival time for process P3 in ms:0 Burst time for process P3 in ms:3 Process AT BT WT -------------------------------------p3 0ms 3ms 0ms p2 0ms 5ms 3ms p1 0ms 10ms 8ms Avg waiting time= 3.67 ms P9:Simulate Shortest job first scheduling to calculate average turnaround time by defining a separate sjf function . 19 | P a g e TEST CASES: Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter the number of processes:3 the name, burst time & arrival time for processes the name of the process:p1 Arrival time for process P1 in ms:0 Burst time for process P1 in ms:10 the name of the process:p2 Arrival time for process P2 in ms:0 Burst time for process P2 in ms:5 the name of the process:p3 Arrival time for process P3 in ms:0 Burst time for process P3 in ms:3 Process AT BT TAT -------------------------------------p3 0ms 3ms 3ms p2 0ms 5ms 8ms p1 0ms 10ms 18ms Avg turn around time= 9.67 ms P 10: Simulate Shortest job first scheduling to display gantt chart. TEST CASES: VIVA QUESTIONS: 1) The optimum CPU scheduling algorithm is (A)FIFO (B)SJF with preemption. (C)SJF without preemption. (D)Round Robin. 2) In terms of average wait time the optimum scheduling algorithm is (A)FCFS (B)SJF (C)Priority (D)RR 3) What are the dis-advantages of SJF Scheduling Algorithm? 4) What are the advantages of SJF Scheduling Algorithm? 5) Define CPU Scheduling algorithm? EXPERIMENT : 1c) 20 | P a g e NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms c) Round Robin AIM: Using CPU scheduling algorithms find the min & max waiting time. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: Round Robin: Example of RR with time quantum=3 Process Burst time aaa 4 Bbb 3 Ccc 2 Ddd 5 Eee 1 ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the burst times of the processes 5. Read the Time Quantum 6. if the burst time of a process is greater than time Quantum then subtract time quantum form the burst time Else Assign the burst time to time quantum. 7.calculate the average waiting time and turn around time of the processes. 8. Display the values 9. Stop PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1. Simulate Round robin scheduling without arrival time to calculate average waiting time. TEST CASES: Enter the number of processes 4 Enter the Burst Time: 8 21 | P a g e 4 9 5 Enter the time Quantum: 5 Scheduling order: 1 2 3 4 1 3 Average Waiting Time: 12.75 P2. Simulate Round robin scheduling with arrival times to calculate average turnaround time. TEST CASES: Enter the number of processes: 4 Enter the arrival times: 0 1 2 3 Enter the burst Time: 8 4 9 5 Enter the time quantum: 5 Scheduling Order: 1 2 3 4 1 3 Average turnaround time: =17.5 Average waiting time = 11 P3. Simulate Round robin scheduling to display the Gantt chart. TEST CASES: Enter the number of processes:4 Enter the Time Quantum : 1 Enter the Arrival Time and Burst Time Enter for Process 0 : 0 8 Enter for Process 1 : 1 4 Enter for Process 2 : 2 9 Enter the Process 3: 3 5 GANTT CHART P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P2 P3 P0 P2 P0 P2 P0 P2 P2 0 26 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 P4. Simulate Round robin scheduling without arrival time to calculate average Turnaround time. TEST CASES: 22 | P a g e P5. Simulate Round robin scheduling with arrival times to calculate average waiting time. TEST CASES: Enter the number of Process : 4 Enter the time Quantum: 4 Enter the Burst Time for Process P1: 8 Enter the Burst Time for Process P2: 4 Enter the Burst Time for Process P3: 9 Enter the Burst Time for Process P4 : 5 Enter the Arrival Time for Process 0 1 2 3 Average Waiting Time: 18.5 P6. Simulate Round robin scheduling without arrival time and print start time, finish time of each process TEST CASES: P7. Simulate Round robin scheduling with arrival time and print start time, finish time of each process TEST CASES: Enter the number of Process : 3 Enter the time Quantum: 4 Enter the Burst Time for Process P1: 24 Enter the Burst Time for Process P2: 3 Enter the Burst Time for Process P3: 3 Enter the Arrival Time for Process 0 0 0 PId 1 2 P ST 0 4 PET 30 7 3 7 10 P8. Simulate Round robin scheduling to display the Gantt chart with a time of 1 sec. TEST CASES: Enter the number of processes:4 23 | P a g e Enter the Time Quantum : 1 Enter the Arrival Time and Burst Time Enter for Process 0 : 0 8 Enter for Process 1 : 1 4 Enter for Process 2 : 2 9 Enter the Process 3: 3 5 GANTT CHART P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P2 P3 P0 P2 P0 P2 P0 P2 P2 0 26 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 P9. Simulate Round robin scheduling with arrivaltime & with time quantum of 4 sec. TEST CASES: Enter the number of Process : 3 Enter the time Quantum: 4 Enter the Burst Time for Process P1: 24 Enter the Burst Time for Process P2: 3 Enter the Burst Time for Process P3: 3 Enter the Arrival Time for Process 0 0 0 P1 P2 P3 P1 0 4 7 10 14 P1 18 P1 22 P1 26 P1 30 P10. Simulate Round robin scheduling with arrivaltime & with time quantum of 1 sec. TEST CASES: Enter the number of processes:4 Enter the Time Quantum : 1 Enter the Arrival Time and Burst Time Enter for Process 0 : 0 8 Enter for Process 1 : 1 4 Enter for Process 2 : 2 9 Enter the Process 3: 3 5 GANTT CHART P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P1 P2 P3 P0 P2 P3 P0 P2 P0 P2 P0 P2 P2 0 26 1 2 3 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 24 | P a g e VIVA QUESTIONS: 1.Round Robin scheduling is used in (A)Disk scheduling. (B)CPU scheduling (C)I/O scheduling. (D)Multitasking 2. What are the dis-advantages of RR Scheduling Algoritm? 3.What are the advantages of RR Scheduling Algoritm? 4.Super computers typically employ _______. 1 Real time Operating system 2 Multiprocessors OS 3 desktop OS 4 None of the above 5. An optimal scheduling algorithm in terms of minimizing the average waiting time of a given set of processes is ________. 1 FCFS scheduling algorithm 2 Round robin scheduling algorithm 3 Shortest job - first scheduling algorithm 4 None of the above 25 | P a g e EXPERIMENT : 1d) NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms d) Priority AIM: Using CPU scheduling algorithms find the min & max waiting time. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: In Priority Scheduling, each process is given a priority, and higher priority methods are executed first, while equal priorities are executed First Come First Served or Round Robin. There are several ways that priorities can be assigned: Internal priorities are assigned by technical quantities such as memory usage, and file/IO operations. External priorities are assigned by politics, commerce, or user preference, such as importance and amount being paid for process access (the latter usually being for mainframes). ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the Priorities of processes 5. sort the priorities and Burst times in ascending order 5. calculate the waiting time of each process wt[i+1]=bt[i]+wt[i] 6. calculate the turnaround time of each process tt[i+1]=tt[i]+bt[i+1] 6. Calculate the average waiting time and average turnaround time. 7. Display the values 8. Stop 26 | P a g e TEST CASES: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: Simulate Priority scheduling without arrival times to calculate average waiting time. TEST CASES: Enter the number of processes 5 Enter the Burst Time for each process: 10 1 2 1 5 Enter the Priority of each Process 3 1 4 5 2 The Average Waiting Time : 8.2ms. P2: Simulate Priority scheduling without arrival times to calculate average turnaround time. TEST CASES: Enter the number of processes 3 Enter the burst time for each process 10 11 27 | P a g e 12 Enter the priority values 3 2 1 Average turnaround time : 21ms. P3: Simulate Priority scheduling with arrival times to calculate average waiting time. TEST CASES: Enter the number of process 3 Enter the CPU Burst Time 10 5 2 Enter the Priority 3 2 1 Enter Arrival Time 0 1 2 Average Waiting Time is : 4 ms P4: Simulate Priority scheduling with arrival times to calculate average turnaround time. TEST CASES: Enter the number of process 3 Enter the CPU Burst Time 10 5 2 Enter the Priority 3 2 1 Enter Arrival Time 0 1 2 Average Turn Around Time is : 10.3 ms 28 | P a g e P5: Simulate Priority scheduling to display only the start time and finish time of each process.(without arrival time). TEST CASES: Enter the no of process : 5 Enter the burst time of each process: 10 1 2 1 5 Enter the priority for each process : 3 1 4 5 2 PId PST PET P1 10 16 P2 0 1 P3 16 18 P4 18 19 P5 1 6 P6: Simulate Priority scheduling to display the start time and finish time of each process and their average waiting time.(without arrival time). TEST CASES: Enter the no of process : 5 Enter the burst time of each process: 10 1 2 1 5 Enter the priority for each process : 3 1 4 5 2 PId PST PET P1 10 16 P2 0 1 P3 16 18 P4 18 19 P5 1 6 The Average Waiting Time: 8.2ms 29 | P a g e P7: Simulate Priority scheduling to display the start time and finish time of each process And their average turnaround time.(without arrival time). TEST CASES: Enter the no of processes : 5 Enter the Burst Times: 10 1 2 1 5 Enter the Priority for each process: 3 1 3 4 2 PId PST PET P1 6 16 P2 0 1 P3 16 18 P4 18 19 P5 1 6 Total Turn Around Time :76 ms Average Turn Around Time : 15.2 ms P8: Simulate Priority scheduling to calculate average waiting time by defining a separate priority function . TEST CASES: Enter the no of process : 5 Enter the burst time of each process: 10 1 2 1 5 Enter the priority for each process : 3 1 4 5 2 PId PST PET P1 10 16 2 0 1 P3 16 18 P4 18 19 P5 1 6 30 | P a g e The Average Waiting Time: 8.2ms P9:Simulate Priority scheduling to calculate average turnaround time by defining a separate Priority function . TEST CASES: Enter the no of processes : 5 Enter the Burst Times: 10 1 2 1 5 Enter the Priority for each process: 3 1 3 4 2 PId PST PET P1 6 16 P2 0 1 P3 16 18 P4 18 19 P5 1 6 Total Turn Around Time :76 ms Average Turn Around Time : 15.2 m P 10: Simulate Priority scheduling to display gantt chart. TEST CASES: Enter the no of processes : 5 Enter the Burst Times: 10 1 2 1 5 Enter the Priority for each process: 3 1 3 4 2 P2 0 P5 1 P1 6 P3 16 P4 18 19 31 | P a g e VIVA QUESTIONS: 1. Priority CPU scheduling would most likely be used in a _____________ os. 2. Cpu allocated process to ___________________ priority. 3. calculate avg waiting time= 4. Maximum CPU utilization obtained with _________________________ 5. Using _______________algorithms find the min & max waiting time. EXPERIMENT: 2a) NAME OF EXPERIMENT: Simulate file Allocation strategies: a) Sequential AIM: Simulate the file allocation strategies using file allocation methods HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: File Allocation Strategies: The main problem is how to allocate disk space to the files so that disk space is utilized effectively band files can be accessed quickly. We have 3 space allocation method. 1. Contiguous allocation (Sequential) It requires each file to occupy a set of contiguous blocks on the hard disk where disk address define a linear ordering on the disk. Disadvantages: i. Difficult for finding space for a new file. ii. Internal and external fragmentation will be occurred. ALGORITHM: 1. 2. 3. 4. 5. 6. Start Read the number of files For each file, read the number of blocks required and the starting block of the file. Allocate the blocks sequentially to the file from the starting block. Display the file name, starting block , and the blocks occupied by the file. stop 32 | P a g e TEST CASES: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: simulate sequential file allocation by creating sequential file and find out no. of sequential block occupied. Input and Output: Test case 1 : Test case 2 : 33 | P a g e P2: Simulate sequential file allocation by creating single sequential file and find out no. of block required by taking input block size for a file. Input and Output: Test case : : P3: Simulate sequential file allocation by creating two files and find out no. of block required by taking input size of file and block size for both files. Input and Output: Test case : 34 | P a g e P4: Simulate sequential file allocation by creating three files and find out no. of block required by taking input size of file and block size for these files. Input and Output: Test case : P5: Simulate sequential file allocation by creating n number of sequential file and find out no. of block required by taking input block size for n number of file. Input and Output: Test case : 35 | P a g e P6: Simulate sequential file allocation by creating single sequential file and find out no. of block required along with block address number. Test case : P7: Simulate sequential file allocation by creating two files and find out no. of block required and block address number by taking input size of file and block size for both files. Test case : 36 | P a g e P8: Simulate sequential file allocation by creating three files and find out no. of block required and block address number by taking input size of file and block size for all files. Test case : P9: Simulate sequential file allocation by creating n number of sequential file and find out no. of block required and block address numbers by taking input block size for n number of file. Input and output Test case : 37 | P a g e P10: Simulate sequential file allocation by creating n number of sequential file and find out no. of block required and block address numbers. Repeat the procedure. Test case : VIVA QUESTIONS: 1.What file access pattern is particularly suited to chained file allocation on disk? 2. Define Sequential File allocation 4. Why we use file allocation strategies? 5.what are the advantages and dis-advantages of Sequential File allocation? 6. The average waiting time =________________________________. 38 | P a g e PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS EXPERIMENT: 2 b) NAME OF EXPERIMENT: Simulate file Allocation strategies: b) Indexed AIM: Simulate the file allocation strategies using file allocation methods HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: Indexed allocation In linked allocation it is difficult to maintain FAT – so instead of that method indexed allocation method is used. Indexed allocation method solves all the problems in the linked allocation by bringing all the pointers together into one location called index block. ALGORITHM: 1. 2. 3. 4. 5. 6. 7. Start Read the number of files Read the index block for each file. For each file, read the number of blocks occupied and number of blocks of the file. Link all the blocks of the file to the index block. Display the file name, index block , and the blocks occupied by the file. stop TESTCASES VIVA QUESTIONS: 1. What file allocation strategy is most appropriate for random access files? 2.Define File? 3.Define Directory? 4. Why we use file allocation strategies? 5.what are the advantages and dis-advantages Indexed Allocation? 39 | P a g e EXPERIMENT: 2 c) NAME OF EXPERIMENT: Simulate file Allocation strategies: c) Linked AIM: Simulate the file allocation strategies using file allocation methods HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: Linked Allocation Linked allocation of disk space overcomes all the problems of contiguous allocation. In linked allocation each file is a linked list of disk blocks where the disk blocks may be scattered anywhere on the disk. The directory contains a pointer to the first and last blocks of the file. Disadvantages : Space required to maintain pointers. ALGORITHM: 1. Start 2. Read the number of files 3. For each file, read the file name, starting block, number of blocks and block numbers of the file. 4. Start from the starting block and link each block of the file to the next block in a linked list fashion. 5. Display the file name, starting block, size of the file , and the blocks occupied by the file. 6. stop Test Case: 40 | P a g e VIVA QUESTIONS: 1.What file access pattern is particularly suited to chained file allocation on disk? 2. What file allocation strategy is most appropriate for random access files? 3. Mention different file allocation strategies? 4. Why we use file allocation strategies? 5. What are the advantages and dis-advantages of each strategies? 6. The ______________contains a pointer to the first and last blocks of the file. EXPERIMENT: 3a NAME OF EXPERIMENT: Simulate MFT . AIM: Simulate Multiple Programming with fixed Number of Tasks (MFT) HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: Multiple Programming with fixed Number of Tasks (MFT) Algorithm Background: IBM in their Mainframe Operating System OS/MFT implements the MFT concept. OS/MFT uses Fixed partitioning concept to load programs into Main memory. Fixed Partitioning: In fixed partitioning concept, RAM is divided into set of fixed partition of equal Size Programs having the Size Less than the partition size are loaded into Memory Programs Having Size more then the size of Partitions Size is rejected The program having the size less than the partition size will lead to internal Fragmentation. If all partitions are allocated and a new program is to be loaded, the program that lead to Maximum Internal Fragmentation can be replaced ALGORITHM: Step1: start Step2: Declare variables. Step3: Enter total memory size. Step4: Read the no of partitions to be divided. Step5: Allocate memory for os. Step6:calculate available memory by subtracting the memory of os from total memory 41 | P a g e Step7: calculate the size of each partition by dividing available memory with no of partitions. Step8: Read the number of processes and the size of each process. Step9: If size of process<= size of partition then allocate memory to that process. Step10: Display the wastage of memory. Step11: Stop . Test Case: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1. Simulate MFT which accepts only even number of memory partitions. Test Case: 42 | P a g e P2) Simulate MFT which accepts Odd number of memory partitions. Test Case: P3. Simulate MFT which accepts the memory capacity in the range from 100 to 500MB. Test Case1: Test Case2: 43 | P a g e P4. Simulate MFT which accepts the memory capacity in the range from 500 to 1000MB. Test Case 1: Test Case2: 44 | P a g e P5. Simulate MFT which accepts the memory capacity in the range from 100 to 500MB and no of partitions are even. Test Case: P6. Simulate MFT which accepts the memory capacity in the range from 100 to 500MB and no of partitions are odd. Test case: P7. Simulate MFT which accepts the memory capacity in the range from 500 to 1000MB and no of partitions are even. Test case: 45 | P a g e P8. Simulate MFT which accepts the memory capacity in the range from 500 to 1000MB and no of partitions are odd. Test case: P9. Simulate MFT which accepts the memory capacity in the range from 1000 to 2000MB. Test case1: Test case2: P10. Simulate MFT which accepts the memory capacity in the range from 2000 to 3000MB. Test Case1: 46 | P a g e Test case2: VIVA QUESTIONS 1. The problem of fragmentation arises in ________. 1)Static storage allocation 2) Stack allocation storage 3 Stack allocation with dynamic binding 4 Heap allocation 2. Boundary registers ________. 1 Are available in temporary program variable storage 2 Are only necessary with fixed partitions 3 Track the beginning and ending the program 4 Track page boundaries 3.The principle of locality of reference justifies the use of ________. 1 Virtual Memory 2 Interrupts 3 Main memory 4 Cache memory 4. In memory management , a technique called as paging, physical memory is broken into fixed-sized blocks called ___________. 1) Pages 2) Frames 3) Blocks 4) Segments 5.Demand paged memory allocation 1 allows the virtual address space to be independent of the physical memory 2 allows the virtual address space to be a multiple of the physical memory size 3 allows deadlock tobe detected in paging schemes 4 is present only in Windows NT EXPERIMENT: 3 b) NAME OF EXPERIMENT: multiple Programming with Varible Number of Tasks (MVT) : AIM: Simulate multiple Programming with Varible Number of Tasks (MVT) 47 | P a g e HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: multiple Programming with Varible Number of Tasks (MVT) Algorithm Background: IBM in their Mainframe Operating ‘System OS/MVT implements the MVT concept. OSIMVT uses Dynamic Partition concept to load programs into Main memory. Dynamic Partitioning: Initially RAM is portioned according to the of programs to be loaded into Memory till such time no other program can be loaded. The Left over Memory is called a hole which is too small too fit any process. When a new program is to be into Memory Look for the partition, Which Leads to least External fragmentation and load the Program. The space that is not used in a partition is called as External Fragmentation ALGORITHM: Step1: start Step2: Declare variables. Step3: Enter total memory size. Step4: Read the no of processes Step5: Allocate memory for os. Step6: read the size of each process Step7:calculate available memory by subtracting the memory of os from total memory Step8: If available memory >= size of process then allocate memory to that process. Step9: Display the wastage of memory. Step10: Stop . Test Cases : 48 | P a g e VIVA QUESTIONS: 1. Explain about MFT? 2. Full form of MFT____________________ 3. Full form of MVT____________________ 4. Differentiate MFT and MVT? 5. The __________________ Memory is called a hole. 6. OSIMVT uses ________________concept to load programs into Main memory. 7. OS/MFT uses ____________________ concept to load programs into Main memory. Experiment No: 4 a) NAME OF EXPERIMENT: Simulate all file Organization Techniques a) Single level directory b) Two Level c) Hierarchical d) DAG Aim: To understand how the file are organized in single level directories. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: The simplest directory structure is the single-level directory. All files are contained in the same directory, which is easy to support and understand 49 | P a g e On early personal computers, this system was common, in part because there was only one user. The world's first supercomputer, the CDC 6600, also had only a single directory for all files, even though it was used by many users at once. A single-level directory has significant limitations, when the number of files increases or when the system has more than one user. Since all files are in the same directory, they must have unique names. If two users call their data file test , then the unique-name rule is violated. Even a single user on a single-level directory may find it difficult to remember the names of all the files as the number of files increases. Algorithm: Step 1: Start Step2: Read the number of directories Repeat Step 3: Read the names of the directory. Step 4: Read the size/ number of files in the directory. Step 5: Read the file names End Repeat Step 6: Display the content of the directory. TEST CASES: P1: Simulate Single level directory for directory of size 3. TEST CASES 1 50 | P a g e TESTCASE2: P2: Simulate Single level directory by using separate function for size of the directory. TESTCASES 51 | P a g e Experiment No: 4 b) NAME OF EXPERIMENT: Simulate all file Organization Techniques b) Two Level Aim: To understand how the file are organized in two level directories. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: It contains one master file directory. Each user has its own user file directory. Each entry in the master file directory points to a user file directory. The issues with two level directories are sharing, system files and grouping problems. Algorithm: Start Step2: Read the number of directories Repeat Step 3: Read the names of the directory. Step 4: Read the sub directory names Step 5: Read the size/ number of files in the directory. Step 6: Read the file names End Repeat Step 7: Display the content of the directory. End 52 | P a g e Test Case Experiment No: 4 c) NAME OF EXPERIMENT: Simulate all file Organization Techniques c) Hierarchical Aim: To understand how the file are organized in hierarchial level directories. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: 53 | P a g e Algorithm: Start Step2: Read the number of directories Repeat Step 3: Read the names of the directory. Step 4: Read the sub directory names Step 5: Read the names of sub-sub directories. Step 6: Read the size/ number of files in the directory. Step 7: Read the file names End Repeat Step 8: Display the content of the directory. End EXPERIMENT: 5 NAME OF EXPERIMENT: Simulate Banker’s Algorithm for Deadlock Avoidance. AIM: Simulate Banker’s Algorithm for Deadlock Avoidance to find whether the system is in safe state or not. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: DEAD LOCK AVOIDANCE To implement deadlock avoidance & Prevention by using Banker’s Algorithm. Banker’s Algorithm: When a new process enters a system, it must declare the maximum number of instances of each resource type it needed. This number may exceed the total number of resources in the system. When the user request a set of resources, the system must determine whether the allocation of each resources will leave the system in safe state. If it will the resources are allocation; otherwise the process must wait until some other process release the resources. Data structures n-Number of process, m-number of resource types. Available: Available[j]=k, k – instance of resource type Rj is available. 54 | P a g e Max: If max[i, j]=k, Pi may request at most k instances resource Rj. Allocation: If Allocation [i, j]=k, Pi allocated to k instances of resource Rj Need: If Need[I, j]=k, Pi may need k more instances of resource type Rj, Need[I, j]=Max[I, j]-Allocation[I, j]; Safety Algorithm 1. Work and Finish be the vector of length m and n respectively, Work=Available and Finish[i] =False. 2. Find an i such that both Finish[i] =False Need<=Work If no such I exists go to step 4. 3. work=work+Allocation, Finish[i] =True; 4. if Finish[1]=True for all I, then the system is in safe state. Resource request algorithm Let Request i be request vector for the process Pi, If request i=[j]=k, then process Pi wants k instances of resource type Rj. 1. if Request<=Need I go to step 2. Otherwise raise an error condition. 2. if Request<=Available go to step 3. Otherwise Pi must since the resources are available. 3. Have the system pretend to have allocated the requested resources to process Pi by modifying the state as follows; Available=Available-Request I; Allocation I =Allocation+Request I; Need i=Need i-Request I; If the resulting resource allocation state is safe, the transaction is completed and process Pi is allocated its resources. However if the state is unsafe, the Pi must wait for Request i and the old resource-allocation state is restored. ALGORITHM: 1. Start the program. 2. Get the values of resources and processes. 3. Get the avail value. 4. After allocation find the need value. 5. Check whether its possible to allocate. 6. If it is possible then the system is in safe state. 7. Else system is not in safety state. 55 | P a g e 8. If the new request comes then check that the system is in safety. 9. or not if we allow the request. 10. stop the program. Test Cases: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: Simulate Bankers algorithm for Deadlock Avoidance for the following : TEST CASE 56 | P a g e P2: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Case P3: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Case: 57 | P a g e P4: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Case P5: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Case: 58 | P a g e P6: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Cases P7: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Cases 59 | P a g e P8: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Cases P9: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Cases 60 | P a g e P10: Simulate Bankers algorithm for Deadlock Avoidance for the following : Test Cases VIVA QUESTIONS: 1. Differentiate deadlock avoidance and fragmentation 2.Tell me the real time example where this deadlock occurs? 3.How do we calculate the need for process? 4.What is the name of the algorithm to avoid deadlock? 5.Banker’s algorithm for resource allocation deals with (A)Deadlock prevention. (B)Deadlock avoidance. (C)Deadlock recovery. (D)Mutual exclusion 61 | P a g e EXPERIMENT: 6 NAME OF EXPERIMENT: Simulate Algorithm for Deadlock prevention. AIM: Simulate Algorithm for Deadlock prevention . HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: 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). 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 Prevention : Difference from avoidance is that here, the system itself is built in such a way that there are no deadlocks. Make sure atleast one of the 4 deadlock conditions is never satisfied. This may however be even more conservative than deadlock avoidance strategy. Algorithm: 1.Start 2.Attacking Mutex condition : never grant exclusive access. but this may not be possible for several resources. 62 | P a g e 3..Attacking preemption: not something you want to do. 4.Attacking hold and wait condition : make a process hold at the most 1 resource at a time.make all the requests at the beginning. All or nothing policy. If you feel,retry. eg. 2-phase locking 5.Attacking circular wait: Order all the resources. Make sure that the requests are issued in the correct order so that there are no cycles present in the resource graph. Resources numbered 1 ... n. Resources can be requested only in increasing order. ie. you cannot request a resource whose no is less than any you may be holding. 6.Stop Test Cases: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases : 63 | P a g e P2: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases: P3: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases P4: Simulate Bankers algorithm for Deadlock Prevention for the following : TestCases 64 | P a g e P5: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Case : P6: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases: P7: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases 65 | P a g e P8: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases: P9: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases: 66 | P a g e P10: Simulate Bankers algorithm for Deadlock Prevention for the following : Test Cases: VIVA QUESTIONS: 1. The Banker’s algorithm is used for ___________________. 2._________ is the situation in which a process is waiting on another process,which is also waiting on another process ... which is waiting on the first process. None of the processes involved in this circular wait are making progress. 3.what is safe state? 4.What are the conditions that cause deadlock? 5.How do we calculate the need for process? 67 | P a g e EXPERIMENT: 7a NAME OF EXPERIMENT: 7) Simulate page replacement algorithms: a) FIFO AIM: Simulate FIFO page replacement algorithms. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: FIFO algorithm: The simpler page replacement algorithm is a FIFO algorithm. A FIFO replacement algorithm associates with each page the time when that page was brought into memory. When a page must be replace, the oldest page is chosen. We can create a FIFO queue to hold all pages in memory. We replace the page at the head of the queue when a page is brought into memory; we insert it at the tail of the queue. 7 0 1 2 7 7 7 0 0 3 0 4 2 3 0 2 2 2 4 4 4 0 0 3 3 3 2 1 1 4 0 0 0 3 2 1 2 0 0 2 2 3 3 0 1 7 0 1 0 7 7 7 1 1 1 0 0 3 2 2 2 1 ALGORITHM: 1. 2. 3. 4. 5. 6. 7. 8. Start Read the number of frames Read the number of pages Read the page numbers Initialize the values in frames to -1 Allocate the pages in to frames in First in first out order. Display the number of page faults. stop Test Case: 68 | P a g e PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: Simulate FIFO(First in First out) Page Replacement algorithm that reads only even no of pages in the range from 10 to 20 and reads the page numbers from the user. Test Case1: Test Case2: P2: Simulate FIFO(First in First out) Page Replacement algorithm that reads only odd no of pages in the range from 7 to 15 and reads the page numbers from the user. Test Case1: 69 | P a g e Test Case2: P3: Simulate FIFO(First in First out) Page Replacement algorithm that accepts random page numbers. (Note: use rand() function) Test case: 70 | P a g e P4: Simulate FIFO(First in First out) Page Replacement algorithm that reads only even no of pages in the range 6 to 14 and accepts random page numbers. (Note: use and() function) Test Case1: 71 | P a g e Test Case2: P5: Simulate FIFO(First in First out) Page Replacement algorithm that reads only odd no of pages 11 to 23 and accepts random page numbers. (Note: use rand() function) Test case1: 72 | P a g e Test Case 2: 73 | P a g e P6: Simulate FIFO(First in First out) Page Replacement algorithm that accepts the page number from the user which is greater than 0 and less than 10. Test Case: P7: Simulate FIFO(First in First out) Page Replacement algorithm that accepts the page number from the user which is greater than 10 and less than 20. Test Case: 74 | P a g e P8: Simulate FIFO(First in First out) Page Replacement algorithm that reads a static array of 10 page numbers. Test Case: 75 | P a g e P9: Simulate FIFO(First in First out) Page Replacement algorithm that reads a static array of 10 page numbers and loads only five pages out of the array in to the frames. . Test Case: P10: Simulate FIFO(First in First out) Page Replacement algorithm that accepts even number of random page numbers . (Note: use rand() function) Test case1: Test Case2: 76 | P a g e VIVA QUESTIONS: 1.Define FIFO? 2.Which of the following statement a)Multiprogramming implies b)Multi-user does not imply c) Multitasking does not imply d)Multithreading implies multi-user is not true? multitasking multiprocessing multiprocessing 3.Define page? 4.Define Frame? 5.Write advantages and dis-advantages of FIFO? EXPERIMENT: 7b) NAME OF EXPERIMENT: 7) Simulate page replacement algorithms: b) LRU AIM: Simulate LRU page replacement algorithms HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. ALGORITHM : 1. 2. 3. 4. 5. 6. Start Read the number of frames Read the number of pages Read the page numbers Initialize the values in frames to -1 Allocate the pages in to frames by selecting the page that has not been used for the longest period of time. 7. Display the number of page faults. 8. stop 77 | P a g e Test Cases: PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS P1: Simulate LRU(least recently used) Page Replacement algorithm that reads only even no of pages in the range from 10 to 20 and reads the page numbers from the user. Test Case1: Test Case2: 78 | P a g e P2: Simulate LRU(least recently used) Page Replacement algorithm that reads only odd no of pages in the range from 7 to 15 and reads the page numbers from the user. Test Case1: Test Case2: 79 | P a g e P3: Simulate LRU(least recently used) Page Replacement algorithm that accepts random page numbers. Test case: P4: Simulate LRU(least recently used) Page Replacement algorithm that reads only even no of pages in the range 6 to 14 and accepts random page numbers. Test Case1: Test Case2: 80 | P a g e P5: Simulate LRU(least recently used) Page Replacement algorithm that reads only odd no of pages 11 to 23 and accepts random page numbers. Test case1: Test Case 2: 81 | P a g e P6: Simulate LRU(least recently used) Page Replacement algorithm that accepts the page number from the user which is greater than 0 and less than 10. Test Case: P7: Simulate LRU(least recently used) Page Replacement algorithm that accepts the page number from the user which is greater than 10 and less than 20. Test Case: 82 | P a g e P8: Simulate LRU(least recently used) Page Replacement algorithm that reads a static array of 10 page numbers. Test Case: P9: Simulate LRU(least recently used) Page Replacement algorithm that reads a static array of 10 page numbers and loads only five pages out of the array in to the frames. . Test Case: P10: Simulate LRU(least recently used) Page Replacement algorithm that accepts even number of random page numbers . Test case1: Test Case2: 83 | P a g e VIVA QUESTIONS: 1.In which of the following page replacement polici es, Bolady’s anomaly occurs? (A)FIFO (B)LRU (C)LFU (D)SRU 2. Explain the difference between FIFO and LRU? 3. The operating system manages ________. 1 Memory 2 Processor 3 Disk and I/O devices 4 All of the above 4. A program at the time of executing is called ________. 1 Dynamic program 2 Static program 3 Binded Program 4 A Process 5.The principle of locality of reference justifies the use of ________. 1 Virtual Memory 2 Interrupts 3 Main memory 4 Cache memory EXPERIMENT: 7c NAME OF EXPERIMENT: 7) Simulate page replacement algorithms: c)LFU AIM: Simulate LFU page replacement algorithms . HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. ALGORITHM: 1. 2. 3. 4. 5. 6. Start Read the number of frames Read the number of pages Read the page numbers Initialize the values in frames to -1 Allocate the pages in to frames by selecting the page that will not be used for the longest period of time. 7. Display the number of page faults. 8. stop Test Case: Reference NO 4-> 6 5 4 Reference NO 2-> 2 5 4 Reference NO 3-> 2 3 4 Reference NO 1-> 2 3 1 84 | P a g e No.of page faults...6 VIVA QUESTIONS: 1. What is the full form of LRU? 2. Explain when page replacement occurs? 3. Which is the best page replacement alg ?why? 4. FIFO scheduling is ________.. 5. Explain various page replacement algorithms? 6. what do u mean by page fault? 85 | P a g e EXPERIMENT: 8 NAME OF EXPERIMENT: Simulate Paging Technique of memory management AIM: Simulate Paging Technique of memory management. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: PAGING Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter is available Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8,192 bytes) Divide logical memory into blocks of same size called pages Keep track of all free frames To run a program of size n pages, need to find n free frames and load program ALGORITHM: 1. 2. 3. 4. 5. 6. Start Read the number of pages Read the page size Allocate the memory to the pages dynamically in non contiguous locations. Display the pages and their addresses. stop VIVA QUESTIONS: 1. The mechanism that bring a page into memory only when it is needed is called _____________ 2. What are the advantages and dis-advantages of paging? 3. Define external fragmentation? 4.__________________________ into blocks of same size called pages. 5._________________________ space of a process can be noncontiguous 6. What is page table? 86 | P a g e 87 | P a g e