Está en la página 1de 10

SHANMUGHA ARTS, SCIENCE, TECHNOLOGY & RESEARCH ACEDEMY (SASTRA) UNIVERSITY

(A University Established under section 3 of the UGC Act, 1956)

TIRUMALAISAMUDRAM, THANJAVUR - 613401

Operating Systems Lab

BICCIC 505 R01 / BITCIT 505 R01 / BCSCCS 505 R02 2013-14

LIST OF EXPERIMENTS

1.

Creation of a child process using fork system

call. 2. 3. Implementing Producer-Consumer system. Implementing Reader-Writer problem.

4. 5. 6. 7. 8. 9.

Implementing Dining Philosopher problem. IPC using Shared Memory System Call. Working with Message Queues. Simulate CPU Scheduling algorithms. Simulate File Allocation strategies. Simulate MVT and MFT. Bankers Algorithm for Dead Lock

10. Simulate Avoidance.

11. Disk Scheduling Techniques 12. Simulate Page Replacement algorithms. 13. Simulate Paging technique of Memory Management. 14. Adding a new system call to Linux kernel

Additional Exercise

1.Study of Linux Kernel source code

1. Creation of a child process using fork system call

Objective: Create a child process using fork system call and ensure both parent and child process executing the same code. Prerequisite: Knowledge of parent/child process, fork command

Procedure: Create the parent process and run the parent code Parent create child process using Fork(). Parent suspended to invoke child Child process invoked and displays child process Id

Pre-Lab: Process creation in Linux Additional Exercise: Pipe Concept, File sharing, Multiple child processes creation

2. Simulating Producer-Consumer problem Objective: Implementation of Producer-Consumer system thereby to get the knowledge about multi-processes synchronization. Prerequisite: Knowledge of Concurrency, Mutual Synchronization and producer-consumer problem

exclusion,

Procedure: Implement Semwait and semsignal functions Implement producer and consumer procedures Producer fills buffer using append Consumer consumes buffer content using take Pre-Lab: Semaphore, multi-processes Additional Exercise: Multiple producer and consumer

3. Implementing Reader-Writer problem Objective: To write a code which solve the readers writers problem thereby which, concurrency problem is solved. Pre-requisite: Knowledge of Concurrency, Mutual Synchronization and producer-consumer problem Procedure: Create a Create a Implement Implement

exclusion,

reader process writer process Semsignal and semwait program giving reader priority

Pre-Lab : Semaphore, multi-processes

Additional Exercise: Writer priority based implementation, readers and writers, Solution based on message passing

multiple

4. Implementing Dining Philosopher problem Objective: To write a code for Dining philosopher problem, thereby understanding how synchronization of processes is achieved. Prerequisite: Knowledge of Concurrency, Deadlock and Starvation Procedure: Array of semaphores are used to keep track of whether a philosopher is eating ,thinking or hungry (trying to acquire the fork). A philosopher may move only into the eating state if neither neighbour is eating. Before starting ,to acquire the fork, a philosopher would do a DOWN on mutex. After replacing the forks ,he would do an UP on mutex. Pre-Lab: Semaphore, multi-processes Additional Exercise: Solution using monitors

5. Inter-Process Communication using Shared Memory System Call Objective: To achieve communication between two process using shared memory concept, so that both process will use a common memory space. Prerequisite: Knowledge of IPC, Shared memory, pipe concept Procedure: Create the server process and create the shared memory portion using shmget() function. Attach the shared memory segment to data space and assign the shared memory a key value say 1234. Write some data into the shared memory. Create the client process. Obtain the shared memory by passing the corresponding key value 1234. Attach the shared memory segment using shmat() function. Read the data put by server in the memory. Alter a character as an acknowledgement for having read the data. Pre-Lab: shmat shmget. Additional Exercise: IPC based on Message passing

6. Working with Message Queues Objective: To implement message queues, which is an other means of inter process communication that does not use file system. Prerequisite: Knowledge of IPC, Message queues Procedure: queue reader reads the messages from the queue prints their contents to standard output. The "queue_reader" is given a number on its command line, which is the priority of messages that it should read.

queue sender creates a message queue, and then starts sending messages with different priorities onto the queue.

Pre-Lab : Msgget(), Msgsnd(), Msgrcv() Additional Exercise: A server program and two client programs, the server can communicate privately to each client individually via a single message queue

7. Simulate CPU Scheduling algorithms Objective: Simulation of CPU Scheduling algorithms thereby understanding how allocation of tasks to the processor is done efficiently. Prerequisite: Knowledge of scheduling algorithms Procedure: Input the number of processes (p1, p2, pn) Input the CPU process time for each of the process. Calculate the waiting time and the average waiting time of all the process for the following scheduling types: First Come First Serve (FCFS) Shortest Job First (SJF): Round Robin Priority based Pre-Lab: Waiting Time, Burst Time and Average calculation Additional Exercise: SRT, Feedback Queue

Waiting

Time

8. Simulate File Allocation strategies Objective: Simulation of File Allocation using both allocation and sequential allocation techniques. Prerequisite: Knowledge File concepts, Allocation methods Procedure:

linked

Create a Record and store the contents in the file. Create fixed sized blocks (arrays and structures). Sequential Allocation: Records are stored in contiguous blocks. Linked Allocation: Records are stored in free blocks and address of next block is stored at the end of the block. Pre-Lab: Prior knowledge of Storage Schema of all File Allocation methods. File operations fopen(), fseek(), ftell(), rewind(), fscanf(), etc,. Additional Exercise: Indexed Allocation

9. Simulate MVT and MFT Objective: Simulation of Multiprogramming with Variable and Fixed number of Tasks. Prerequisite: Concept multiprogramming, MVT and MFT Procedure: Create various Tasks (copying file contents, storing information in editor and drawing a picture, etc,.). Execute the Tasks (Threads) at an interval of time to implement MVT. Get the opinions to execute notepad, paint application for fixed number of tasks (MFT). Pre-Lab: Multiprocesses, Fork, Pipe Additional Exercise: Both MVT and MFT implemented and dynamically chosen one of them

10. Simulate Bankers Algorithm for Dead Lock Avoidance Objective: To write a code for bankers effective allocation of resource deadlock.

algorithm which make thereby avoids the

Procedure: Get the number of processes and resources

Create the following data structures: Available Number of available resources of each types. Max Maximum demand of each process. Allocation Number of resources of each type currently allocated to each process. Need Remaining resource need of each process. (Max-Allocation) Use Safety algorithm and Resource-Request algorithm.

Pre-Lab: Prior knowledge avoidance methods.

of

deadlocks

and

all

deadlock

Additional Exercise: Deadlock detection, Deadlock recovery

11. Disk Scheduling Techniques Objective: Write the code for some of the disk algorithms which schedules disk space to the process based on its algorithmic nature. Prerequisite: Knowledge of disk scheduling algorithms. Procedure: Implement scheduling algorithms listed below: First in First out Shortest Seek Time First Shortest Service Time First Scan Pre-Lab: Seek time, transfer time etc. Additional Exercise: C-SCAN, Look

scheduling requesting

12. Simulate Page Replacement algorithms Objective: explores achieved. Simulate Page the concept of Replacement algorithms virtual memory and how which it is

Prerequisite: Knowledge of Paging concepts, replacement algorithms

Procedure: Create a queue of pages Select a page replace based on the following approaches: Least Frequently Used, Least Recently Used and Optimal page replacement Pre-Lab :

Simple paging FIFO, MRU, LFU, Second-chance and

Additional Exercise: memory compaction.

13. Simulate Paging technique of Memory Management Objective: Simulation of Paging technique of Memory Management, which convert the logical address into physical address. Prerequisite: Knowledge of Paging, Frames, Memory management Procedure: Get the range of Physical and Logical addresses. Get the Page Size. Get the Page Number of the data. Construct Page Table by mapping Logical address to Physical address. Search Page Number in the Page Table and locate the Base Address. Calculate the Physical address of the data. Pre-Lab: Paging, Page replacement, Address calculation methods Additional Exercise: Simulation of segmentation

thrashing,

Implementation

of

14. Adding a new system call to Linux kernel Objective: To develop our own system call adding it to the linux kernel.

and

execute

it

by

Prerequisite: Knowledge of linux kernel, System calls Procedure:

1) Download the latest version of the 2.6 Linux kernel from www.kernel.org. 2) Unzip and untar the kernel directory into /usr/src/. 3) In /usr/src/Linux-x.x.x/kernel/, Create a new file myservice.c to define your system call. 4)In /usr/src/Linux-x.x.x/include/asm/unistd.h, define an index for your system call. Your index should be the number after the last system call defined in the list. 5)Also, you should increment the system call count. 6)In /usr/src/Linux-x.x.x/arch/i386/kernel/entry.S, you should define a pointer to hold a reference to your system call routine. 7) Add your system call to the Makefile in /usr/src/Linuxx.x.x/kernel/Makefile. Add your object after the other kernel objects have been declared. 1) Make your system from /usr/src/Linux-x.x.x 2) Add a new boot image to Lilo, by editing /etc/lilo.conf. Your lilo configuration will vary slightly. 3) Making a user test file. You also need to copy your edited unistd.h from /usr/src/Linux-x.x.x/include/asm/ to /usr/include/kernel/ because it contains your system calls index. Reboot into your new kernel and compile your user test program to try out your system call. You will know if it worked if you see a kernel message in /var/log/kernel/warnings announcing that your service is running. Pre-Lab: shell commands

También podría gustarte