Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

OS List

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Operating Systems Lab

List of Lab Projects

Project 1—Sleeping Teaching Assistant


A university computer science department has a teaching assistant (TA) who helps
undergraduate students with their programming assignments during regular office hours. The
TA’s office is rather small and has room for only one desk with a chair and computer. There are
three chairs in the hallway outside the office where students can sit and wait if the TA is currently
helping another student. When there are no students who need help during office hours, the TA
sits at the desk and takes a nap. If a student arrives during office hours and finds the TA sleeping,
the student must awaken the TA to ask for help. If a student arrives and finds the TA currently
helping another student, the student sits on one of the chairs in the hallway and waits. If no chairs
are available, the student will come back at a later time.
Using POSIX threads, mutex locks, and semaphores, implement a solution that coordinates the
activities of the TA and the students. Details for this assignment are provided below.
Using Pthreads, begin by creating n students. Each will run as a separate thread. The TA will run
as a separate thread as well. Student threads will alternate between programming for a period
of time and seeking help from the TA. If the TA is available, they will obtain help. Otherwise, they
will either sit in a chair in the hallway or, if no chairs are available, will resume programming and
will seek help at a later time. If a student arrives and notices that the TA is sleeping, the student
must notify the TA using a semaphore. When the TA finishes helping a student, the TA must check
to see if there are students waiting for help in the hallway. If so, the TA must help each of these
students in turn. If no students are present, the TA may return to napping.

Project 2: Cigarette-Smokers Problem


Consider a system with three smoker processes and one agent process. Each smoker
continuously rolls a cigarette and then smokes it. But to roll and smoke a cigarette, the smoker
needs three ingredients: tobacco, paper, and matches. One of the smoker processes has paper,
another has tobacco, and the third has matches. The agent has an infinite supply of all three
materials. The agent places two of the ingredients on the table. The smoker who has the
remaining ingredient then makes and smokes a cigarette, signalling the agent on completion. The
agent then puts out another two of the three ingredients, and the cycle repeats. Write a program
to synchronize the agent and the smokers.

Project 3: Concurrent server


Servers can be designed to limit the number of open connections. For example, a server may
wish to have only N socket connections at any point in time. As soon as N connections are made,
the server will not accept another incoming connection until an existing connection is released.
Write Concurrent server with semaphores that can be used to limit the number of concurrent
connections.

Project 4: Multilevel feedback queue algorithm


Write a CPU scheduler for n number of processes using multilevel feedback queue algorithm.
Consider three levels of queue. In first level, RR(tq=2) is used to execute all the processes and in
second level, RR(tq=4) is used to execute remaining incomplete processes. If the processes still
not complete, these are brought in last level (FCFS) queue.

Project 5: Fair-Share Scheduling


In FCFS, SJF, RR scheduling algorithms, each process is scheduled on its own, without regard to
who its owner is. As a result, if user 1 starts up 9 processes and user 2 starts up 1 process, with
round robin or equal priorities, user 1 will get 90% of the CPU and user 2 will get only 10% of it.
To prevent this situation, some systems take into account who owns a process before scheduling
it. In this model, each user is allocated some fraction of the CPU and the scheduler picks processes
in such a way as to enforce it. Thus if two users have each been promised 50% of the CPU, they
will each get that, no matter how many processes they have in existence.
As an example, consider a system with two users, each of which has been promised 50% of the
CPU. User 1 has four processes, A, B, C, and D, and user 2 has only 1 process, E. If round-robin
scheduling is used, a possible scheduling sequence that meets all the constraints is this one:
A E B E C E D E A E B E C E D E ...
On the other hand, if user 1 is entitled to twice as much CPU time as user 2, we might get
A B E C D E A B E C D E ...
Numerous other possibilities exist of course, and can be exploited, depending on what the notion
of fairness is. Write a fair-share scheduler with your own assumptions.

Project 6— Multithreaded Sudoku Solution Validator


A Sudoku puzzle uses a 9 × 9 grid in which each column and row, as well as each of the nine 3 × 3
subgrids, must contain all of the digits 1 · · · 9. Figure 4.19 in the textbook presents an example
of a valid Sudoku puzzle. This project consists of designing a multithreaded application that
determines whether the solution to a Sudoku puzzle is valid.
There are several different ways of multithreading this application. One suggested strategy is to
create threads that check the following criteria:
• A thread to check that each column contains the digits 1 through 9
• A thread to check that each row contains the digits 1 through 9
• Nine threads to check that each of the 3 × 3 subgrids contains the digits 1 through 9
This would result in a total of eleven separate threads for validating a Sudoku puzzle.

Project 7: Multithreaded Searching Algorithm


A multithreaded program where multiple threads are used to execute parallel search on the data
and reduce the overall search time. Thread synchronization issues have to be taken care of.
Project 8: Multithreaded Sorting Algorithm
Write a multithreaded sorting program that works as follows: A list of integers is divided into two
smaller lists of equal size. Two separate threads (which we will term sorting threads) sort each
sublist using a sorting algorithm of your choice. The two sublists are then merged by a third
thread—a merging thread—which merges the two sublists into a single sorted list.
Because global data are shared cross all threads, perhaps the easiest way to set up the data is to
create a global array. Each sorting thread will work on one half of this array. A second global array
of the same size as the unsorted integer array will also be established. The merging thread will
then merge the two sublists into this second array.

Project 9: Multithreaded tic-tac-toe program


A tic-tac-toe program between two players, every player represented by a thread. Each player
gets it turn to make a move. It makes a random move on the empty cells. After every move, if a
thread wins it completes the program and indicate other thread to finish. Proper
synchronization, communication is required to be done meticulously between threads.

Project 10: Multithreaded Scheduling


Students have to implement two scheduling algorithms named FCFS and SJF via two threads
named fcfsT and sjfT. The task is to be carried out in following two steps as follows
1. [Initialization] Initially main() thread randomly generates 10 processes having ids 1 to 10.
The arrival time (AT) and burst time (BT) of the processes are generated randomly.
2. [Scheduling] Two threads are created and initialized which simulates the working of FCFS
and SJF algorithms and display completion time (CT), turnaround time (TAT) and response time
(RT) of each process in a tabular form.

Project 11: Drawing Competition


The problem is regarding the drawing competition in a school. There are two primary
participants in the game: one teacher (T) and three students (S1, S2 and S3). A student need
four resources to complete a drawing and these are pencil, paper, sharpener and eraser.
Initially S1 is issued paper, sharpener and eraser. S2 is issued paper, pencil and eraser. S3 is
issued paper, eraser and pencil.
Teacher puts any one of the three resources (pencil, eraser and sharpener) on a table and all
the three students try to take that resource. Only one student will be able to complete the
drawing. Teacher keeps repeating the process until all the three students completed their
drawing operation.

Project 12: Fastest Finger First


The problem is regarding the implementation of Fastest Finger First (FFF) step of Kaun Banega
Crorpati (KBC) show. The problem is to be implemented using threads named AB (Amitabh
Bachaan), ten player threads (P1 to P10) and one Result Thread. The game uses a structure as
follows
typedef struct
{
char question[100]; // Question to be Displayed
char *options[4]; // Four Options of the Question
int displayedSequence[4]; // Sequence in which options are to be displayed
int correctSequence[4]; // Correct Sequence of the Question
int answerBoard[5]; // Slot for Answering Questions
}FFFGame;
The working of each thread is as follows
1. AB thread displays question and waits for players to answer
2. Each player answers a question and writes in answerBoard data field. answerBoard[0]
indicates the id of the thread and answerBoard[1] to answerBoard[4] indicates the options
given by the thread. [Note : Only one thread should write in answerBoard at a given time and
other thread should only write when answer is not read by the resultant thread]
3. A resultant thread first reads the answer by the player and after reading it removes the
answer from answerBoard so that another player can write their answer. The resultant thread
stores the answer of a player in a suitable structure. When all the players have written their
answer then resultant player declares the winner if any.

Project 13: Deadlock Detection


A system has M resources named A1, A2,.. Am having no of units as n1, n2, n3, and n4
respectively. Note: M, n1, n2, n3,.. are user inputs. There are N processes in the system namely
P1, P2, P3,..Pn. Note: N is user input.
Each Process randomly makes a ‘M’ (user input) requests for any random resource ( A1, A2,..
Am). The request will be considered as genuine only if the process has not made a request for
the same resource in the past.
You have to construct resource allocation graph and search for cycles in the graph.
You have to determine whether there exists a deadlock or not.

Project 14—UNIX Shell and History Feature


This project consists of designing a C program to serve as a shell interface that accepts user
commands and then executes each command in a separate process. This project consists of two
parts: Creating a Child Process and Creating a History Feature explained in detail under
Programming Projects section of Chapter 3 in the Textbook.

Project 15: UNIX Shell with I/O redirection and pipe


This project consists of designing a C program to serve as a shell interface that accepts user
commands and then executes each command in a separate process. The program should also
support for I/O redirection and pipe, like ls | wc > file1.

Project 16: Creating Kernel Modules


Proceed through the steps described under Programming Projects section of Chapter 2 in the
Textbook, to create the kernel module and to load and unload the module. Be sure to check the
contents of the kernel log buffer using dmesg to ensure you have properly followed the steps.

Project 17: Designing a Virtual Memory Manager


This project consists of writing a program that translates logical to physical addresses for a virtual
address space of size 216 = 65,536 bytes. Your program will read from a file containing logical
addresses and, using a TLB as well as a page table, will translate each logical address to its
corresponding physical address and output the value of the byte stored at the translated physical
address. The goal behind this project is to simulate the steps involved in translating logical to
physical addresses. Complete explanation is given under Programming Projects section of
Chapter 9 in the Textbook.

Project 18: Multithreaded Sorting Algorithm with Mergesort


Write a multithreaded program to sort an array of n integers using mergesort technique. The
array to be supplied into n segments, the value of that shall be given at the command prompt.

Project 19: Scheduling Simulator


Create a simulator for scheduling a given set of processes in user space only. The simulator should
read fr6m a configuration file a set of parameters for each process: Length of time for which
process will execute, priority of the process and the preferred scheduling policy - FIFO or Round
Robin, the time at which the process executes and if it is a CPU intensive process _or an I/O
intensive process. Apart from this read the quantum of time given to each process and the
number of priority levels for scheduling the process. Now simulate a scheduling algorithm which
uses FIFO/Round Robin with priority based scheduling. At the end of the run print the following
quantities for each process:
a. Number of times the process was scheduled.
b. A timeline for the process containing the state transitions - Ready, waiting,
c. Running and Terminated and the timestamp for each transition.
d. Time taken to complete the process.
e. Number of times the process waited for I/O.
f. The priority of the process and preferred scheduling algorithm.
After printing the above values print the average time of completion for each process.

Project 20: Process Tree


Write a program to create a process tree as shown in Figure #1 and print the process identifiers
in Inorder traversal form. The height (depth) of the tree is a command line argument. The
program should create simultaneously executing processes in the same level as quickly as
possible before child’s execution starts. Each process should print its process identifier and its
parent process identifier by using the function getpid ( ) and getppid ( ) respectively. Your
program should not create an orphan process while execution. The parent process should also
print the exit status of its child processes.

Figure #1

Project 21: Command line interpreter


Implement a command line interface which will execute all UNIX commands and save
intermediate values of pipe (|) and redirection operation (>>) commands with the help of files
related system calls and dup2. The program should work as follows
The program should provide a command interface with following features:
It should support internal commands like Start, End, LogComm, LogInt, UnLogComm, and
UnLogInt. These commands are just to enable / disable various functionalities of the
interface. They are not a part of UNIX system. The functionalities of these commands are
as follows
Start  start the functioning of your own interface
End  Exit from your interface
LogComm  Log all the commands executing in the command interface with status as
success/failure.
LogInt  Logs intermediate values of pipe or redirection commands in standard format
specified
UnLogInt  stop logging intermediate values of pipe and redirection commands
UnLogComm  Stop logging commands executed in the interface.
The new command interface should support all the commands in UNIX system and should
save the intermediate value of pipe and redirection commands into a file with the
following format
ls –l | wc | wc
The intermediate output file (name of the file should be InterLog.txt) should print the
output as follows
ls –l output is
[ls –l] drwxrwxrwx …………………………
[ls –l] –rwxr—r-- ……………………………
****************************************

ls –l | wc output is
[ls –l | wc]
****************************************
ls –l | wc | wc output is
[ls –l | wc | wc]
****************************************
If the LogComm is on then the system should create a file named CommLog.txt which will
store information about all the commands executed in the system as follows
ls –l Success
ls –l | wc Success
ls –l | wc | wc Success
ls Success
ls >> a1.txt Success

The command interface should work as follows for redirection.


ls >> a1.txt
The intermediate file will store ls output alone. Whereas a1.txt will contain information
what it had earlier and the output of ls.

Project 22: Multithreaded Server using pipe


Write a program to communicate between client and server process using two pipes to
implement the following task:
The parent sends to the child an array of numbers and child calculates various statistical values
for these numbers and sends back to the parent. Child is multithreaded and will then create three
separate worker threads. One thread will determine the average of the numbers, the second will
determine the maximum value, and the third will determine the minimum value.
Project 23: Shell and System Calls
This project consists of two parts. In the first, you will design and implement an extremely simple
shell that knows how to launch new programs, and also recognizes three internal commands
(exit, cd, and execcounts), which are described at the following link:
https://homes.cs.washington.edu/~zahorjan/homepage/Tools/LinuxProjects/SysCall/proj1.htm
l The first two internal commands will work by calling existing system calls (exit and chdir); the
third internal command will work by calling a new system call that you will design and implement.
So, in the second part of this assignment, you will design and implement the execcounts system
call. This will involve making changes to the Linux kernel source code. The semantics of
the execcounts system call, and some hints on how to go about implementing it are also
described at the given link.

Project 24:Quick Sort Algorithm


Implement a multithreaded program to sort sufficiently big data using quick sort algorithm. The
data to be read from File. Also, show that multithreaded version of the program is faster than
the serial program.
Project 25: Merge Sort Algorithm
Implement a multithreaded program to sort sufficiently big data using quick sort algorithm. The
data to be read from File. Also, show that multithreaded version of the program is faster than
the serial program.
Project 26: Spell Checker
Implement a spell checker to check spelling of words of the text contained in a very large file.
Create multiple threads to perform the spelling check from different positions of the file so as to
make the spelling check faster. Wherever there is a spelling mistake, the program shall print the
line number and the word misspelled word.
Project 27: Shell Script to Display System State
Write a shell script to displays a summary of the system state as: Total Memory and available
Free Memory
Project 28: Process Monitoring using Shell Script
Write a shell script which monitors the processes running on a system time to time - say every
01 minutes. If any running process is down it shows a message and ask the alternative option
(e.g. Kill, go to next process)
Project 29: Deadlock Detection
Consider a system with N number of processes currently in the system and M number of resource
types. Processes are holding some resources and are requesting for other resources. Write an
application to detect deadlock using adjacency matrix.
Project 30:Radix Sort Algorithm
Implement a multithreaded program to sort sufficiently big data using radix sort algorithm. The
data to be read from File. Also, show that multithreaded version of the program is faster than
the serial program.
Project 31: Counting Sort Algorithm
Implement a multithreaded program to sort sufficiently big data using Counting sort algorithm.
The data to be read from File. Also, show that multithreaded version of the program is faster than
the serial program.
Project 32: Heap Sort Algorithm
Implement a multithreaded program to sort sufficiently big data using heap sort algorithm. The
data to be read from File. Also, show that multithreaded version of the program is faster than
the serial program.
Project 33: Binary Search Algorithm
A process spawns a child process which runs a binary search program (written by you) and
communicates the index position of the element searched to the parent process which then
prints the index position.
Project 34: Linear Search Algorithm
A process spawns a child process which runs a linear search program (written by you) and
communicates the index position of the element searched to the parent process which then
prints the index position.

Project 35: File Handling in Client Server Application


This project is built on the client -server model. Project helps the unrelated client and server
processes communicate through named Pipe also known as FIFO. In this project, the client first
reads the file name from STDIN and writes the file name to the pipe. Server reads the file name
from the pipe and tries to open the file. If the Open is successful, Server reads the contents of
the file and writes it to the pipe. After writing it to the pipe, Client reads from the pipe and
displays the file contents on the standard output. If the Open is not successful, the Server writes
the error message to the pipe. Client reads the error message and displays the error message.
Also perform synchronization to read or write on file.

Project 36: Haunted House


Suppose there are Npass passenger threads and Ncar. The passengers line up to take rides in
cars. Each car can hold a certain number of passengers P. When the car returns from a tour of
the Haunted House and empties, it will let the passengers on line take a haunted house tour by
taking seats in the car upto the car's passenger capacity. The cars wait and they will depart when
the last passenger to take a seat will signal. (binary semaphores). However as soon as the
passenger is allowed to get in the car, as a polite gesture he will first yield. The last passenger
that gets in the car will have the car started. Throughout the ride the passengers sleep for a long
time. The car thread will wake up the passengers sleep by using interrupt(). The car goes out on
tour only when it is full, so if there is not enough passengers when the car returns, the car waits
until it fills. There is a possibility that the last car will not be completely filled so an exception can
be made. After a passenger completes three rides, he will wonder for a while and then attempt
to leave. Passengers leave in a specific order, N will join N-1, N-1 joins N-2,..., first passenger
doesn't join any thread. The last passenger to leave will also have the cars terminate.

Project 37: Matrix Multiplication


Multiply two very order matrices using multithreaded program. Compare the time taken with the
single threaded program.
Project 38: Stopwatch
We are making stopwatch using threads in which one thread is used to display time in minute:
second format, and the second thread is used to perform stop, pause and restart operations on
the first thread. User will give the inputs to start, reset and stop.

Project 39 : Virtual Scheduler


Implement a virtual scheduler. This virtual scheduler runs on top of the existing linux scheduler
which you should not change. It consists of two major components: a generator and a scheduler.
The generator is responsible for generating the processes at regular interval. The scheduler
maintains a ‘Ready Queue’ which contains the set of runnable processes at any time-instance. It
chooses/schedules one of the runnable processes according to the scheduling algorithm for
execution. Next it sends a ‘notify’ signal to only that chosen/scheduled process and ‘suspend’
signal to all other processes. Depending on the signal (‘notify’/’suspend’’) received from the
scheduler, the processes can either (re)start processing or wait until it’s scheduled again. Once
all the processes terminate, the scheduler also terminate. After building this simulation
framework, you have to evaluate different scheduling strategies and evaluate their performance
in terms of average response time, average waiting time and average turnaround time
Project 40 : Modified Producer-Consumer Problem
Implement a system which ensures synchronization in a producer-consumer scenario. You also
have to demonstrate deadlock condition and provide solutions for avoiding deadlock. In this
system a main process creates 6 producer processes and 6 consumer processes who share two
queues. The producer's job is to generate a piece of data, put it into the queue and repeat. At
the same time, the consumer process consumes the data i.e., removes it from the queue. Out of
the 6 producers, odd numbered producers and consumers can access queue-1 and even
numbered producers and consumers can access queue-2. In the implementation, you are asked
to ensure synchronization and mutual exclusion. For instance, the producer should be stopped if
the buffer is full and that the consumer should be blocked if the buffer is empty. You also have
to enforce mutual exclusion while the processes are trying to acquire the resources.

Project 41: Rail Manager


Assume, you have the above rail-crossing scenario. Trains may come from all the four different
directions. You have to implement a system where it never happens that more than one train
crosses the junction (shaded region) at the same time. Every train coming to the junction, waits
if there is already a train at the junction from its own direction. Each train also gives a precedence
to the train coming from its right side (for example, right of North is West) and waits for it to
pass. You also have to check for deadlock condition if there is any. Each train is a separate process.
Your task will be to create a manager which creates those processes and controls the
synchronization among them.

Project 42: Simple Linux Device Driver


This project includes a practical Linux driver development. It includes the following:
 Kernel logging system
 How to work with character devices
 How to work with user-level memory from the kernel
Student has to step-by-step program for
 Loading and unloading modules
 Registering character device
 Specifying a name of the device
 The file_operations structure
 The printk function
 Using memory allocated in user mode
 Build system of a kernel module
 Loading and using a module

Project 43: FUSE (Filesystem in Userspace)

FUSE (Filesystem in Userspace) is an interface for userspace programs to export a filesystem to


the Linux kernel. The FUSE project consists of two components: the fuse kernel module
(maintained in the regular kernel repositories) and the libfuse userspace library (maintained in
this repository). libfuse provides the reference implementation for communicating with the FUSE
kernel module.
A FUSE file system is typically implemented as a standalone application that links with libfuse.
libfuse provides functions to mount the file system, unmount it, read requests from the kernel,
and send responses back. libfuse offers two APIs: a "high-level", synchronous API, and a "low-
level" asynchronous API. In both cases, incoming requests from the kernel are passed to the main
program using callbacks. When using the high-level API, the callbacks may work with file names
and paths instead of inodes, and processing of a request finishes when the callback function
returns. When using the low-level API, the callbacks must work with inodes and responses must
be sent explicitly using a separate set of API functions.

Project 44: Rock Paper Scissor game


This game has one master and two players. The rules are given below: 1. If first player chooses
rock and second player chooses scissor then master will give one point to the first player. 2. If
first player chooses rock and second player chooses paper then master will give one point to the
second player. 3. If first player chooses scissor and second player chooses paper then master will
give one point to the first player. 4. If both the players chooses the same either rock, paper and
scissor, then master will give the half point each to both players. 5. Player reaching more than 10
points first will win the game. Write a C program to implement the following rock paper scissor
game as simulating master as parent and players as two child process. The parent program P first
creates two pipes and spawns two child processes C and D. One of the two pipes is meant for
communications between P and C, and the other for communications between P and D.

Project 45: Advanced Rock Paper Scissor game


Write a C program to implement the following game. The parent program P first creates two
pipes, and then spawns two child processes C and D. One of the two pipes is meant for
communications between P and C, and the other for communications between P and D. Now, a
loop runs as follows. In each iteration (also called round), P first randomly chooses one of the
two flags: MIN and MAX (the choice randomly varies from one iteration to another). Each of the
two child processes C and D generates a random positive integer and sends that to P via its pipe.
P reads the two integers; let these be c and d. If P has chosen MIN, then the child who sent the
smaller of c and d gets one point. If P has chosen MAX, then the sender of the larger of c and d
gets one point. If c = d, then this round is ignored. The child process who first obtains ten points
wins the game. When the game ends, P sends a user-defined signal to both C and D, and the child
processes exit after handling the signal (in order to know who was the winner). After C and D
exit, the parent process P exits. During each iteration of the game, P should print appropriate
messages (like P's choice of the flag, the integers received from C and D, which child gets the
point, the current scores of C and D) in order to let the user know how the game is going on.

Project 46: Website Navigation

‘N’ web users are accessing a website, their navigation pattern (sequence of web pages such as
a,b,c,d etc.) is recorded in a trie data structure. Your code should allow multiple users to read
from the trie data structure but only one user to update the data structure at a time. Also identify
the most visited page in the given patterns.
Project 47: Movie Booking System Simulation

Write the code to simulate the movie booking system in a theatre, using semaphores. The
problem should include the number of spectators in a theatre at a time, number of seats allotted
to a spectator, time allotted etc.
Project 48: Salesman Consumer Problem
Create five threads of a process ‘salesperson’, indicating five salesperson in a company and ten
threads ‘customers’. Show the communication among all threads showing how many items are
sold by which salesperson to whom. Assign unique ids to customers and salesperson. Print the
items sold with salesperson id and customer id.
Project 49: Printer Scheduling
Consider there is a single printer for CCE and CSE Dept. Write a scheduling algorithm such that
the single page print can interrupt the previously maintained queue and printed at the top
priority. Other documents are scheduled at the FCFS fashion. Your algorithm must avoid the
starvation using the concept of aging. Also write the code for the above algorithm.
Project 50: Computer Maintenance Scheduling
Consider that seven students and faculties are raising tickets on IT-Infra for installing a software,
resolving the hardware issues, system failure etc. Write the code to schedule the tickets to
minimize the waiting time and maximize the throughput. Think about the additional information,
if required. The acknowledgement for satisfied solutions to be recorded for future use.

You might also like