operating systems (13cs203) list of projects a.y. 2015 ... · operating systems (13cs203) list of...

33
Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform some user defined operations. 2. Implementation of Interactive terminal to perform single/multi tasking by providing different user defined commands. 3. Implement quota command with different shell script functions 4. Implementation of Password Security and Management System using shell script. 5. Implementation of Menu Driven Database with basic operations using shell script. 6. Project to implement different file operations using shell script. 7. Project to Simulate various CPU scheduling algorithms 8. Simulation of Multi level queue /with feedback CPU Scheduling 9. Project to simulate Various Page replacement algorithms 10. Project to Simulate Bankers algorithm to avoid Deadlocks 11. Project to Simulate Various File Allocation Techniques 12. Project to implement Classical problems of Inter Process Communication 13. Project to implement First fit, best fit, and worst fit Memory allocation Algorithms using Linked lists, Queues and Pthreads. 14. Project to implement/Simulate various memory management techniques 15. Project to simulate Memory management-Paging techniques 16. Project to implement the Various Memory partitioning techniques 17. Project to simulate General Graph directory system 18. Project to simulate singe level, Two level and hierarchical directory system. 19. Parallel file copy and Print server 20. The Not Too Parallel Virtual Machine 21. Internet Radio 22. CD Database Application Using DBM 23. TCP/IP echo Client Server, Multithreaded and Internet chat Server 24. Implementation of TFT Protocol using Internet Sockets 25. Memory allocation 26. Time, System limits and options 27. Server Performance 28. WWW Redirecting 29. THE CD COLLECTION APPLICATION 30. CD database application using MySQL 31. CD database application using IPC facilities 32. Race conditions using fork, semaphores, Record locking, sleep and pipes 33. ls, more, internet Day Time Server, Chef/Cook server 34. Reverse, Monitor and process topology Utility using Pipes, FIFOS and Message Queues, Shared Memory, Sockets and pthreads.

Upload: phungtruc

Post on 15-Apr-2018

218 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester

1. Implementation of a tiny shell to perform some user defined operations.

2. Implementation of Interactive terminal to perform single/multi tasking by providing

different user defined commands.

3. Implement quota command with different shell script functions

4. Implementation of Password Security and Management System using shell script.

5. Implementation of Menu Driven Database with basic operations using shell script.

6. Project to implement different file operations using shell script.

7. Project to Simulate various CPU scheduling algorithms

8. Simulation of Multi level queue /with feedback CPU Scheduling

9. Project to simulate Various Page replacement algorithms

10. Project to Simulate Bankers algorithm to avoid Deadlocks

11. Project to Simulate Various File Allocation Techniques

12. Project to implement Classical problems of Inter Process Communication

13. Project to implement First fit, best fit, and worst fit Memory allocation Algorithms

using Linked lists, Queues and Pthreads.

14. Project to implement/Simulate various memory management techniques

15. Project to simulate Memory management-Paging techniques

16. Project to implement the Various Memory partitioning techniques

17. Project to simulate General Graph directory system

18. Project to simulate singe level, Two level and hierarchical directory system.

19. Parallel file copy and Print server

20. The Not Too Parallel Virtual Machine

21. Internet Radio

22. CD Database Application Using DBM

23. TCP/IP echo Client Server, Multithreaded and Internet chat Server

24. Implementation of TFT Protocol using Internet Sockets

25. Memory allocation

26. Time, System limits and options

27. Server Performance

28. WWW Redirecting

29. THE CD COLLECTION APPLICATION

30. CD database application using MySQL

31. CD database application using IPC facilities

32. Race conditions using fork, semaphores, Record locking, sleep and pipes 33. ls, more, internet Day Time Server, Chef/Cook server 34. Reverse, Monitor and process topology Utility using Pipes, FIFOS and Message

Queues, Shared Memory, Sockets and pthreads.

Page 2: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

35. Implementation of Fileserver with pipes, FIFOS and Message Queues, Shared Memory, sockets and pthreads.

36. Sequence-number increment Problem using shared memory, Memory Mapping, Sockets, mutex locks, File Locking, condition variables, semaphores and pthreads.

37. Implementation of Producer-consumer problem using using pthreads, condition variables, mutex, semaphores, Pipes, FIFOS and Message Queues, Shared Memory and Sockets.

38. Building a Simple Shell 39. UNIX Utilities Token ring Simulator using pipes, Dining Philosophers Problem using

Pthreads, Mutex, condition variables, Monitors and Semaphores. 40. Traversing Directories in BFS and DFS 41. Multithreaded Prime, Sorting and Sudoku Solution Validator 42. Parallel Monte Carlo Pi 43. Parallel matrix-vector multiplication, estimate pi and Implementation of a barrier 44. Pthreads linked list and thread safe tokenize

Page 3: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

K L UNIVERISTY

2/4 B.Tech

PROJECTS SPECIFICATION

COURSE: OPERATING SYSTEMS COURSE CODE:13CS203

1. Develop a tiny shell to perform some user defined operations.

The project is to design a shell by Making use of various system calls, signals, signal handlers, user

input handling, data structures implementation.

The shell must be able to do the following:

Module 1:

1. to read commands from standard input and execute them in a loop until a

built-in command exit is issued (we call these processes the foreground processes; there is

always at most one of these at any particular time);

2. be able to redirect the standard input and output of commands by prefixing them with built-in

commands in file and out file;

Module 2:

3. be able to terminate (involuntarily) the foreground process when user presses ^C and return

back to the mini-shell;

4. be able to interrupt the foreground process temporarily, when user presses ^Z, returning to

the mini-shell;

Module 3:

5. be able to execute any number of processes in background (i.e., in parallel with the

foreground process), including in particular, the ability to start another process while a

process has been temporarily suspended;

6. inform the user when the background process finishes or is waiting for an input from the

terminal;

7. be able to inform the user what commands are executing in the background by issuing the

built-in command jobs, this should include information about the state of the process (i.e.,

suspended, background, waiting for input, etc.) and about what file(s) is the background

process using for standard input and output);

Module 4:

8. be able to terminate involuntarily a background processes by issuing the built-in

command kill job-number.

9. to be able to resume a process or to make a background process into the foreground process

(i.e., the one that currently interacts with the terminal) by issuing the fg job-number

command.

Page 4: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

2. Develop an Interactive terminal to perform single/multi tasking by providing different user

defined commands .

The Idea is to develop a RUN kind of terminal to perform single/multitasking by defining the

functions to perform different tasks.

Module 1:Identifying the Functions to implement

Module 2:Designing the Terminal

Module 3:Testing the terminal for single/multi tasking

Module 4: Single- and multi-user

3. . Develop a project for the following requirement :

The project is to develop a script for checking designed to run at user login and to analyse the output

of the quota command to determine what percentage of the quota is currently in use. If usage is over

some limit, then the script will need to print a warning reporting the current percent usage.

Module 1: Creating the funtion funtionquota() for getting the quota of all file system inside the /home

directory

Module 2: Creating the funtion funtioncheckresult() for getting the results according to the condition

i.e. if the quota limit is greater than 90 then perform certain action.

Module 3: Creating the funtion functionlargestdirectory () to get the list of 10 biggest directories in

your home directory. In this funtion we have to assume that the result is in kBytes.

Module 4: Creating the funtion functionlargestdirectory () to get the list of 10 biggest directories in

your home directory. In this funtion we do not have to assume that the result is in kBytes instead it

shows the size of the Directories in a user frienly manner.

Page 5: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

4. Develop a project to implement Password Security and Management System using shell

script.

The project is to design a system which asks the user to enter the passphrase to decrypt the file with

controlling the popup window.In the Specification we were said to store the file in some of the

specific location under /home directory.

If you want to test with your own encrypted file then you have to provide your own file in $TEMP

and the file name to which it decrypts in $ORGFILE

Module 1:Encryption File Management System.

Module 2)Add an entry for System or Account

Module 3)Lookup Userid and Password Combination

Module 4)Modify the stored data

5. Develop a project to implement Menu Driven Database to implement basic operations using

shell script.

Module 1:Encryption System.

Module 2)Inserting a record for System or Account

Module 3)Search Userid and Password Combination

Module 4)Updating and Modifying the stored data

6.Develop a project to implement different file operations using shell script.

This Project is to design an Interactive Menu Item, which performs some basic operations

such as Renaming the File, Lowering the File name, copy/Move, Text Search. In this script some of

the menu items works on the Absolute or Relative Pathnames

Module 1: Rename the File, Display list of files

Module 2:Rename the Files to LowerCase, Create Link

Module 3: Copy or Move the File, Change Permissions

Module 4:Find text inside the File, find size of file

7. Develop a Project to Simulate Following CPU scheduling algorithms.

i.First Come First Serve

ii. Shortest Job First

iii. Priority

iv.Round Robin

Simulation of Cpu Scheduling

Module :

7.1 FCFS (First Come First Serve) CPU Scheduling algorithm :

Description :

Page 6: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

FCFS is very simple - Just a FIFO queue, like customers waiting in line at the bank or

the post office or at a copying machine

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.2SJF( Short Job First) with Non Preemption Cpu Scheduling algorithem :

Description:

The idea behind the SJF algorithm is to pick the quickest fastest little job that

needs to be done, get it out of the way first, and then pick the next smallest fastest job to do

next.( Technically this algorithm picks a process based on the next shortest CPU burst, not

the overall process time. )

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.3SJF with Preemption process mechanism :

Description:

Preemptive SJF is sometimes referred to as shortest remaining time first scheduling.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.4 Priority Cpu Scheduling algorithem :

Description:

Priority scheduling is a more general case of SJF, in which each job is assigned a

priority and the job with the highest priority gets scheduled first. ( SJF uses the inverse of the

next expected burst time as its priority - The smaller the expected burst, the higher the

priority. )

Note that in practice, priorities are implemented using integers within a fixed range,

but there is no agreed-upon convention as to whether "high" priorities use large numbers or

small numbers. This book uses low number for high priorities, with 0 being the highest

possible priority.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

Page 7: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.5RR (Round Robin) Cpu scheduling process :

Description:

Round robin scheduling is similar to FCFS scheduling, except that CPU bursts are

assigned with limits called time quantum.

When a process is given the CPU, a timer is set for whatever value has been set for a

time quantum.

If the process finishes its burst before the time quantum timer expires, then it is

swapped out of the CPU just like the normal FCFS algorithm.

If the timer goes off first, then the process is swapped out of the CPU and moved to

the back end of the ready queue.

The ready queue is maintained as a circular queue, so when all processes have had a

turn, then the scheduler gives the first process another turn, and so on.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.6 RR using SJF:

Description:

Like RR & internally using SJF

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.7 RR with Mean value :

Description:

RR and find the mean value of burst time of all process

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

Page 8: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

7.8 RR with Median value :

Description:

RR and find the median value of the burst time of all process

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.9 SJF Preemptive and Non Preemptive:

Description:

Like SJF, here we consider the different execution priorities

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.10 Arrival time in increasing and decreasing order :

Description:

Here we consider the arrival times of various jobs using various orders of burst time

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.11 SJF, FCFS:

Description:

In SJF internally use the FCFS

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

7.12 Preemptive SJF ,FCFS :

Description:

In preemptive internally use the FCFS

Page 9: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8. Simulation of Multi level queue /with feedback CPU Scheduling

8.1 Multi level queue Cpu Scheduling process:

Description:

When processes can be readily categorized, then multiple separate queues can be

established, each implementing whatever scheduling algorithm is most appropriate for that

type of job, and/or with different parametric adjustments.

Scheduling must also be done between queues, that is scheduling one queue to get

time relative to other queues. Two common options are strict priority ( no job in a lower

priority queue runs until all higher priority queues are empty ) and round-robin ( each queue

gets a time slice in turn, possibly of different sizes. )

Note that under this algorithm jobs cannot switch from queue to queue - Once they

are assigned a queue, that is their queue until they finish.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.2 Multilevel feedback queue cpu scheduling :

Description:

Multilevel feedback queue scheduling is similar to the ordinary multilevel queue

scheduling described above, except jobs may be moved from one queue to another for a

variety of reasons:

If the characteristics of a job change between CPU-intensive and I/O intensive, then it

may be appropriate to switch a job from one queue to another. Aging can also be

ncorporated, so that a job that has waited for a long time can get bumped up into a higher

priority queue for a while.

Multilevel feedback queue scheduling is the most flexible, because it can be tuned for

any situation. But it is also the most complex to implement because of all the adjustable

parameters. Some of the parameters which define one of these systems include:

Page 10: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

The number of queues. The scheduling algorithm for each queue. The methods used to

upgrade or demote processes from one queue to another. ( Which may be different. ) . The

method used to determine which queue a process enters initially.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.3 Multi level with SJF :

Description:

Multilevel and SJF

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.4 Comparision of all CPU Scheduling mechanisms:

Description:

Using all FCFS,SJF,Priority,RR etc.

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the average

waiting time and average turnaround time.

Output Specification

For each of the scheduling policies, display/print the Gantt chart, compute and print the average

waiting time and average turnaround time.

8.5 Comparison of Multi level & feedback :

Description:

Multilevel queue and multilevel queue feed back

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.6 Multi level with SJF :

Description:

Multilevel and SJF

INPUT:

Page 11: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.7 Multi level queue feedback with SJF :

Description:

Multilevel queue feedback using sjf

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.8 Multi level with mean :

Description:

Multilevel using mean

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.9 Multi level with feedback mean :

Description:

Multilevel and SJF

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.10 Multi level with median :

Description:

Multilevel using median

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

Page 12: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

8.11 Multi level with feedback using median :

Description:

Multilevel feed back with the help of median

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

8.12 Multi level & feedback comparison using all factors :

Description:

Multilevel feedback using all factors

INPUT:

Given the list of processes, their CPU burst times and arrival times.

OUTPUT:

For each of the scheduling policies, display/print the Gantt chart, compute and print the

average waiting time and average turnaround time.

9. Develop a Project to simulate Following Page replacement algorithms

i. First In First Out

ii.Least Recently Used

iii. Optimal

9.1. To implement page replacement algorithm FIFO.

DESCREPTION:

The First-In-First-Out policy treats the page frames allocated to a process as a circular buffer

and pages are removed in round robin style. All that is required is a pointer that circles through the

page frames of the process. This is therefore, one of the simplest page replacement policies to

implement the logic behind this choice, other than its simplicity is that one is replacing the page that

has been in memory the largest. A page fetched into memory a long time ago may have now fallen

out of use.

Input:

Pages numbers (reference string)

Output:

Loaded pages on FIFO into Main memory

Page 13: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

9.2. To implement the algorithm for the page replacement LRU:least recently used

DESCRIPTION:

The least recently used*lru)policy replaces the page in memory that has not been referenced

for the longest time.By the principle of locality this would be the page least likely to be referenced in

the near future.The problem with the approach is the difficulty in implementation. One approach

would to tag each page with the time of its last reference.This would have to be done at each memory

reference, both instruction and data.Even if the hardware if you support such scheme, the overhead

would be tremendous

Input:

Pages numbers (reference string)

Output:

Loaded pages on LRU into Main memory

9.3

AIM:To implement the algorithm for the Optimal page replacement .

DESCRIPTION:

Replace the page that will not be used for the longest period of time. Use of this page-

replacement algorithm guarantees the lowest possible page-fault rate for a fixed number of

frames.

Input:

Pages numbers (reference string)

Output:

Loaded pages on Optimal basis into Main memory

9.4

To write a program for simulation of paging technique for memory management

DESCRIPTION:

The main memory is partitioned into equal fixed size chunks, which are relatively

small and that each process is also divided into small fixed size chunks of same size. Then

the chunks of a process, known as pages, would be assigned to available chunks of

memory known as frames or page frames. At a given point in time, some of the frames in

memory are in use and some are free.

10.. Develop a Project to Simulate Bankers algorithm to avoid Deadlocks

. Methods for Handling Deadlock

In most cases, the event that each process is waiting for is the release of some resource currently

possessed by another member of the set. In other words, each member of the set of deadlocked

processes is waiting for a resource that is owned by a deadlocked process. None of the processes can

run, none of them can release any resources, and none of them can be awakened. The number of

processes and the number and kind of resources possessed and requested are unimportant. This result

holds for any kind of resource, including both hardware and software

ensure that the system never enters a deadlocked state:

o deadlock prevention

Page 14: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

o deadlock avoidance

deadlock detection and recovery: allow the system to enter a deadlocked state, then deal with

and eliminate the problem

ignore the problem: approached used by many operating systems including UNIX and

Windows, and the Java VM

10.1Deadlock Avoidance Algorithms

Two deadlock avoidance algorithms:

resource-allocation graph algorithm

Banker's algorithm

Resource-allocation graph algorithm

only applicable when we only have 1 instance of each resource type

claim edge (dotted edge), like a future request edge

when a process requests a resource, the claim edge is converted to a request edge

when a process releases a resource, the assignment edge is converted to a claim edge

cycle detection: O(n²)

Banker's Algorithm: a classic deadlock avoidance algorithm

more general than resource-allocation graph algorithm (handles multiple instances of each

resource type), but

is less efficient

10.2 Deadlock Detection

requires an algorithm which examines the state of the system to determine whether a deadlock

has occurred

requires overhead

o run-time cost of maintaining necessary information and executing the detection

algorithm

o potential losses inherent in recovering from deadlock

Single instance of each resource type

wait-graph

Pi → Pj = Pi > Rq and Rq → Pj

detect cycle: O(n²)

overhead: maintain the graph + invoke algorithm

Resource-allocations graphs for deadlock detection

Implement the BANKER’S ALGORITHM using dead lock Avoidance

Implement the BANKER’S ALGORITHM USING DEADLOCK Prevention

Page 15: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Implement the BANKER’S ALGORITHM USING DEADLOCK Detection

11.Develop a Project to Simulate the Following File Allocation Techniques.

i. Contiguous File Allocation

Contiguous allocation requires that each file occupy a set of contiguous blocks on the disk. Disk

addresses define a linear ordering on the disk. With this ordering, assuming that only one job is

accessing the disk, accessing block b +1 after block b normally requires no head movement. When

head movementis needed (from the last sector of one cylinder to the first sector of the next cylinder),

the head need only move from one track to the next. Thus, the number of disk seeks required for

accessing contiguously allocated files is minimal, as is seek time when a seek is finally needed.

Contiguous allocation of a file is defined by the disk address and length (in block units) of the first

block. If the file is n blocks long and starts at locationb, then it occupies blocks b, b + 1, b + 2, ..., b +

n − 1.

ii. Linked Allocation

Linked allocation solves the external-fragmentation and size-declaration problems of contiguous

allocation. However, in the absence of a FAT, linked allocation cannot support efficient direct access,

since the pointers to the blocks are scattered with the blocks themselves all over the disk and must be

retrievedin order. With linked allocation, each file is a linked list of disk blocks; the disk blocks may

be scattered anywhere on the disk. The directory contains a pointer to the first and last blocks of the

file.

Iii Indexed Allocation

Indexed allocation solves this problem by bringing all the pointers together into one location: the

index block. Each file has its own index block, which is an array of disk-block addresses.

The ith entry in the index block points to the ith block of the file.

Module 1: To identify the files and functions required to implement the allocation methods

Module 2: To implement contiguous file allocation

Module 3: To implement linked allocation

Module 4:To implement Indexed allocation

12. Develop a Project to implement Classical problems of Inter Process Communication.

Inter process communication (IPC) is the transfer of data among processes. For example, a Web

browser may request a Web page from a Web server, which then sends HTML data. This transfer of

data usually uses sockets in a telephone-like connection. In another example, you may want to print

the filenames in a directory using a command such as ls | lpr. The shell creates an ls process and a

separate lpr process, connecting the two with a pipe, represented by the “|” symbol. A pipe permits

one-way communication between two related processes. The is process writes data into the pipe, and

the lpr process reads data from the pipe. In this chapter, we discuss five types of inter process

communication: n Shared memory permits processes to communicate by simply reading and writing

to a specified memory location. n Mapped memory is similar to shared memory, except that it is

associated with a file in the file system. n Pipes permit sequential communication from one process to

a related process. n FIFOs are similar to pipes, except that unrelated processes can communicate

because the pipe is given a name in the file system. n Sockets support communication between

Page 16: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

unrelated processes even on different computers. These types of IPC differ by the following criteria: n

Whether they restrict communication to related processes (processes with a common ancestor), to

unrelated processes sharing the same file system, or to any computer connected to a network n

Whether a communicating process is limited to only write data or only read data n The number of

processes permitted to communicate n Whether the communicating processes are synchronized by the

IPC—for example, a reading process halts until data is available to read In this chapter, we omit

discussion of IPC permitting communication only a limited number of times, such as communicating

via a child’s exit value. To implement Application using Inter Process communication (using shared

memory, pipes or message queues). Description: Inter-process communication (IPC) is a set of

techniques for the exchange of data among multiple threads in one or more processes. Processes may

be running on one or more computers connected by a network. IPC techniques are divided into

methods for message passing, synchronization, shared memory, and remote procedure calls (RPC).

The method of IPC used may vary based on the bandwidth and latency of communication between the

threads, and the type of data being communicated

Module 1: To implement Producer-Consumer problem using IPC, Develop a project to exchange

message between server and client using message queue.

Module2: To implement Readers-Writers problem, Develop a project to establish a communication

between process using shared memory.

Module3: To implement Dining Philosophers problem, Develop a project to establish a

communication between processes using pipes

Module4: To implement sleeping barbers problem

13.. Develop a project to implement the following algorithms.

i. First fit algorithm

First-fit: Allocate the first hole that is big enough.

ii. Best fit algorithm

Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size.

Produces the smallest leftover hole.

iii. Worst fit algorithm.

Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole.

How to satisfy a request of size n from a list of free holes.

Description:

To implement first fit, best fit and worst fit storage allocation algorithms for memory

management. Description A set of holes, of various sizes is scattered through the memory at any

given time. When a process arrives and needs the memory, the system searches for a hole that is large

Page 17: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

enough for this process. The first-fit, best-fit and worst-fit are strategies used to select a free hole from

the set of available holes. Implementation details Free space is maintained as a linked list of nodes

with each node having the starting byte address and the ending byte address of a free block.

Each memory request consists of the process-id and the amount of storage space required in

bytes. Allocated memory space is again maintained as a linked list of nodes with each node having the

process-id, starting byte address and the ending byte address of the allocated space. When a process

finishes (taken as input) the appropriate node from the allocated list should be deleted and this free

disk space should be added to the free space list. [Care should be taken to merge contiguous free

blocks into one single block. This result in deleting more than one node from the free space list and

changing the start and end address in the appropriate node]. For allocation use first fit, worst fit and

best fit.

Module1: Implement a GUI based screen to select the dynamic memory allocation methods. Select

the one of the methods to allocate the arrived request. Allocate memory requirements for processes

using first fit allocation.

Module2: Implement first fit algorithm to allocate a file, Allocate memory requirements for processes

using best fit allocation.

Algorithm for allocate (n)

size(block) = n + size(header)

Scan free list for first block with nWords >= size(block)

If block not found

Failure (time for garbage collection!)

Else if free block nWords >= size(block) + threshold*

Split into a free block and an in-use block

Free block nWords = Free block nWords - size(block)

In-use block nWords = size(block)

Return pointer to in-use block

Else

Unlink block from free list

Return pointer to block

Module 3: Implement Best fit allocation algorithm to allocate a file, Allocate memory requirements

for processes using worst fit allocation

Algorithm for allocate (n)

size(block) = n + size(header)

Scan free list for smallest block with nWords >= size(block)

If block not found

Failure (time for garbage collection!)

Else if free block nWords >= size(block) + threshold*

Split into a free block and an in-use block

Free block nWords = Free block nWords - size(block)

In-use block nWords = size(block)

Return pointer to in-use block

Else

Unlink block from free list

Return pointer to block

Page 18: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

*Threshold must be at least size(header) + 1 to leave room for header and link

Threshold can be set higher to combat fragmentation

Module 4: Implement Worst fit allocation algorithm to allocate a file, Design and develop a menu

based system for implement first fit,best fit and worst fit allocations..

Algorithm for allocate (n)

size(block) = n + size(header)

Scan free list for largest block with nWords >= size(block)

If block not found

Failure (time for garbage collection!)

Else if free block nWords >= size(block) + threshold*

Split into a free block and an in-use block

Free block nWords = Free block nWords - size(block)

In-use block nWords = size(block)

Return pointer to in-use block

Else

Unlink block from free list

Return pointer to block

*Threshold must be at least size(header) + 1 to leave room for header and link

Threshold can be set higher to combat fragmentation

14.Develop a project to implement the following memory management Concepts

i. Allocation of Blocks of memory

Multiple-partition allocation

Hole – block of available memory; holes of various size are scattered throughout memory.

When a process arrives, it is allocated memory from a hole large enough to accommodate it.

Operating system maintains information about:

a) allocated partitions b) free partitions (hole)

Dynamic Storage-Allocation Problem

Static memory allocation is simple and convenient, but it's not sufficient for

everything.

Two basic operations in dynamic storage management:

o Allocate a given number of bytes

o Free a previously allocated block

Two general approaches to dynamic storage allocation:

o Stack allocation (hierarchical): restricted, but simple and efficient.

o Heap allocation: more general, but less efficient, more difficult to implement.

Stack Allocation

A stack can be used when memory allocation and freeing are partially predictable: memory is freed in opposite order from allocation.

Page 19: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Ifalloc(A) then alloc(B) then alloc(C), then it will

be free(C) then free(B) then free(A).

Example: procedure call. X calls Y calls Y again.

Stacks are also useful for lots of other things: tree traversal, expression evaluation, top-down recursive descent parsers, etc.

A stack-based organization keeps all the free space together in one place.

Heap Allocation

Heap allocation must be used when allocation and release are unpredictable

Memory consists of allocated areas and free areas (or holes). Inevitably end up with lots of holes.

Goal: reuse the space in holes to keep the number of holes small, keep their size large.

Fragmentation: inefficient use of memory due to holes that are too small to be

useful. Stack allocation is perfect: only one hole.

Typically, heap allocation schemes use a free list to keep track of the storage

that is not in use. Algorithms differ in how they manage the free list.

Best fit: keep linked list of free blocks, search the whole list on each allocation, choose block that comes closest to matching the needs of the allocation, save

the excess for later. During release operations, merge adjacent free blocks.

First fit: just scan list for the first hole that is large enough. Free excess. Also

merge on releases. Most first fit implementations are rotating first fit.

Best fit is not necessarily better than first fit!

First fit tends to leave "average" size holes, while best fit tends to leave some very large ones, some very small ones. The very small ones can't be used very easily.

Problem: over time, holes tend to fragment, approaching the size of the smallest objects allocated; this makes it hard to allocate large objects.

Bit map: used for managing storage that comes in fixed-size chunks (e.g. disk blocks, or 32-byte chunks).

o Keep a large array of bits, one for each chunk.

o If bit is 0 it means chunk is in use, if bit is 1 it means chunk is free.

Pools: keep a separate linked list for each popular size.

o Allocation is fast, no fragmentation.

Storage Reclamation

How do we know when dynamically-allocated memory can be freed?

o Easy when a chunk is only used in one place.

o Reclamation is hard when information is shared: it can't be recycled until all of

the sharers are finished.

o Sharing is indicated by the presence of pointers to the data. Without a pointer, can't access (can't find it).

Two problems in reclamation:

o Dangling pointers: better not recycle storage while it's still being used.

o Memory leaks: storage gets "lost" because no one freed it even though it can't ever be used again.

Page 20: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Reference counts: keep count of the number of outstanding pointers to each chunk of memory. When this becomes zero, free the memory. Example:

Smalltalk, file descriptors in Unix. Works fine for hierarchical structures.

Garbage collection: storage isn't freed explicitly (using free operation), but

rather implicitly: just delete pointers.

o When the system needs storage, it searches through all of the pointers (must be able to find them all!) and collects things that aren't used.

o If structures are circular then this is the only way to reclaim space.

o Most garbage collectors also compact memory, moving objects to coalesce all

free space.

o Makes life easier on the application programmer, but garbage collectors are incredibly difficult to program and debug, especially if compaction is also done.

o Examples: many modern languages, such as Java.

How does garbage collection work?

o Must be able to find all objects.

o Must be able to find all pointers to objects.

o Pass 1: mark. Go through all statically-allocated and procedure-local variables,

looking for pointers. Mark each object pointed to, and recursively mark all objects it points to. The compiler has to cooperate by saving information about

where the pointers are within structures.

o Pass 2: sweep. Go through all objects, free up those that aren't marked.

Garbage collection is often expensive: 10-20% or all CPU time in systems that use it.

15.Develop a Project to simulate Memory management-Paging technique.

Virtual memory is a technique that allows the execution of processes which are not completely

available in memory. The main visible advantage of this scheme is that programs can be larger than

physical memory. Virtual memory is the separation of user logical memory from physical memory.

This separation allows an extremely large virtual memory to be provided for programmers when only

a smaller physical memory is available. Following are the situations, when entire program is not

required to be loaded fully in main memory.

User written error handling routines are used only when an error occured in the data or computation.

Certain options and features of a program may be used rarely.

Many tables are assigned a fixed amount of address space even though only a small amount of the

table is actually used.

The ability to execute a program that is only partially in memory would counter many benefits.

Less number of I/O would be needed to load or swap each user program into memory.

A program would no longer be constrained by the amount of physical memory that is available.

Each user program could take less physical memory, more programs could be run the same time, with

a corresponding increase in CPU utilization and throughput

Module 1: Implement t he project dynamic memory allocation.

Page 21: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Module 2: Implement an algorithm to allocate contiguous memory allocation

Module 3: Implement an algorithm to allocate paging scheme

Module 4: Implement an algorithm to allocate free frames

16.Develop a Project to implement the following Memory partitioning techniques

Description: In this the memory is divided in to parts and process is fit into it. The process which is

best suited in to it is placed in the particular memory where it suits. We have to check memory

partition. If it suits, its status should be changed.

Module 1: Implement the project Multiple partitions-(MFT)-Fixed length

Modulo 2: Implement the project Multiple partitions-(MVT)-Variable length

Module 3: Implement an algorithm to perform Internal Fragmentation

Module 4: Implement an algorithm to perform External Fragmentation

17. Develop a Project to simulate General Graph directory system

Description:

To implement main directory and its sub-directory structure as a general graph directory for

Directory management. Most directory structures are hierarchical one top‐level directory (root) within

directory are file & other directories can define the location of a file/directory by its path from the

root, traverse up and down if hard links (shared access) or soft links (aliasing) are allowed, then cycles

are possible

Modulo 1: Develop a project to ensure that there are cycles in General-Graph Directory.

Modulo 2: Develop a project to avoid traversing a component in a cycle while searching.

Modulo 3: Implement an algorithm to release orphan cycles (garbage collection)

Modulo 4: Implement an algorithm to traverse up and down if shred access and aliasing are allowed

18. Develop a project to simulate singe level, Two level and hierarchical directory system.

DESCRIPTION: Most directory structures are hierarchical one top‐level directory (root) within

directory are file & other directories can define the location of a file/directory by its path from the

root, traverse up and down if hard links (shared access) or soft links (aliasing) are allowed, then cycles

are possible

Modulo 1: Single Level Directory System

Modulo 2: Two Level Directory System

Modulo 3: Tree Structured Directory System

Modulo 4 : Hierarchical Directory System

Page 22: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

19. Parallel file copy and Print server

This project uses mutex locks, semaphores, condition variables and signals.

Implementations for different types of stopping conditions are developed with careful attention to

error handling and shutdown. This project has two topics a parallel file copy and a print server.

Parallel file copy uses bounded buffer and print server uses unbounded buffer.

Objectives:

Learn about producer-consumer synchronisation

Experiment with complex synchronisation problems

Explore how ending conditions effect synchronisation

Use a large number of threads in a realistic application

Understand thread interaction and synchronisation

Reference: Text Book-UNIX System Programming: Communication, Concurrency and Threads.

Chapter 16.

20.The Not Too Parallel Virtual Machine:

PVM(Parallel Virtual Machine) provides a high level, but not transparent, system for a user to

coordinate tasks spread across workstations on a network. This project describes a threaded

implementation of the Not Too Parallel Virtual Machine (NTPVM) dispatcher, a simplified PVM

system. The multithreaded implementation illustrates the interaction between threads and fork,

providing a semi realistic application in which to explore complex thread interactions.

Objectives:

Learn about distributed processing

Experiment with threads and I/O

Explore the interaction of threads with fork

Use threads to solve a real problem

Understand the use of objects in thread design

Reference: Text Book-UNIX System Programming: Communication, Concurrency and Threads.

Chapter 16.

21.Internet Radio:

This project is to send audio streams over a network under various

conditions. The project explores timing, buffering and packet loss, as well as synchronization and a

dynamic number of receivers.

Objectives:

Learn about streaming media

Experiment with UDP, multicast and TCP

Explore timing strategies for multimedia

Use audio in a real application

Use threads to solve real problem

Understand synchronization with multiple receivers

Reference: Text Book-UNIX System Programming: Communication, Concurrency and Threads.

Chapter 16.

22.CD Database Application Using DBM

To implement database application to store information about the CD’s in a store or in your House.

This application is to be implemented using DBM database. Application requires updating, searching

and displaying the data. Single or multiple files can be used to store the data. Requires command line

interface to interact with the database created. SQL can also be used instead of DBM. Simply it

involves managing the data of CD’s using a new Environment DBM which will be the part you will

learn throughout the Project. For More Understanding Refer chapter 3, page no. 82 in the source

below.

Page 23: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Reference: Chapter 7 Page No.289, Beginning LINUX Programming, Neil Matthew 4th

Edition

23. TCP/IP echo Client Server, Multithreaded and Internet chat Server.

A simple Chat application for the hosts on a network using internet sockets i.e AF_INET in socket

call. Freedom to use any of the internet protocols. One to one chat between two hosts where one will

act as the server and the other as client using sockets in UNIX. Authentication may be an

implementation before initiation of chat. A simple interface with timestamps of the message sent

along with some information of the sender.

Write TCP clients and servers using either IPv4 or IPv6 for chat application and echo client server.

Show how to make your clients and servers use the network’s name service, and also describes how to

make them IP-version-independent. Understand what is going on in the Sockets implementation to the

API calls.

Reference: TCP/IP Socket Programming in C, 2nd edition, by Michael J Donahoo, Kenneth

Calvert Publisher: Elsevier, Chapters: 2, 6

Reference: Page no. 608, Beginning LINUX programming

24.Implementation of TFT Protocol using Internet Socket

TFTP is a simple protocol for transferring files, implemented on top of the User Datagram

Protocol (UDP) using port number 69. In TFTP, communication is initiated by the client issuing a

request to read or write a file on the server. If the server grants the request, the connection is opened

and the file is sent in fixed length blocks of 512 bytes. Each data packet contains one block of data,

and must be acknowledged by an acknowledgment packet before the next packet can be sent. A data

packet of less than 512 bytes signals termination of a transfer. If a packet gets lost in the network, the

intended recipient will timeout and may retransmit their last packet (which may be data or an

acknowledgment), thus causing the sender of the lost packet to retransmit that lost packet. The sender

has to keep just one packet on hand for retransmission, since the lock step acknowledgment

guarantees that all older packets have been received.

However, there is no fixed Rule to use the port no. 69 or to use the User Datagram protocol, anything

can be used. The project is to be implemented using internet sockets i.e AF_INET in socket call which

involves communication between a client and a server.

Reference: Page no. 608, Beginning LINUX programming,

Unix Network Programming by stevens

25.Memory allocation

In this project, you will implement a memory allocator for the heap of a user-level process. You will

build your own version of malloc() and free().

Memory allocators have two distinct tasks. First, the memory allocator asks the operating system to

expand the heap portion of the process's address space by calling either sbrk() or mmap(). Second, the

memory allocator doles out this memory to the calling process. This involves managing the free list of

memory and finding a contiguous chunk of memory that is large enough for the user's request; when

the user later frees memory, it is added back to this list.Try to allocate memory in stacks.

Reference: The Linux Programming Interface, chapter: 7, pgno: 139

26. Time, System limits and options

In this project you should execute all time conversion functions and timezones the project should

involve the following using system calls

converting time_t to printable form

converting between time_t and broken -down time

converting btween broken-down time and printable form

updating the system clock

the software clock

Implement a project in such a way that it will retrieve the system limits at run time, file related limits

at run time, indeterminate limits, IPC and using system options.

Reference: The Linux Programming Interface, chapter: 10, pgno:18

Page 24: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

Reference: The Linux Programming Interface, chapter: 11, pgno: 211

27.Server Performance

Objective:

One server can serve many clients. Parallelism can be achieved by multiple processes, by

multiple threads within a process, by asynchronous I/O and events within a single process thread or by

combinations of these approaches. The outline of the project is to compare the efficiency of thread-

per-request versus process-per-request implementations for different offered loads. Reference: Unix System Programming, Chapter: 22.

28.WWW Redirecting

Objective:

Learn the basic operation of the HTTP protocol

Experiment with a ubiquitous distributed system

Explore the operation of the World Wide Web

Use client-server communication

Understand the roles of tunnels, proxies and gateways

Reference: Unix System Programming, Chapter:19

29.THE CD COLLECTION APPLICATION

A unix/linux program to implement cd collection application using 'curses.h' library functions which

helps to display information clearer on the screen and scrolling window is used for track listings .the

application can be implemented using files and database .

Database should be created with following options:

1.)Add new Records

2.)Count the Records

3.)List the Records

4.)Remove Records

5.)Update Record information

6.)Quit

what to do:

the application must perform the following operations

Drawing the menu

Adding CDs to the database

Retrieving and displaying CD data

Reference: Beggining linux programing. Page No:83

References: beginers linux programming :chapter 6 Managing Text-Based Screens with curses

pg.no 240

30. CD database application using MySQL

A unix/linux program to imlement a cd datbase aplication using mysql databas as backend server and

c as the front end application .the user can maintain database of all the cd using mysql database and c

program .the application must acess data from data from c . a cpi is required to use with mysql .

What to do:

creating relations between entitys

accessing databases using c

retriving and displaying values using c

modifying data through c

References: beginners Linux programming :Chapter 8:MySql pg-358,

visit www.mysql.com for more information

31. CD database application using IPC facilities

Page 25: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

A linux/unix program using facilities of inter process communication .the program can use different

combination of the three ipc facilites provided by posix to pass information

and handle reqests and responses directly using message queus. If the amounts of data that you needed

to pass were large, you could have considered passing the actual

data in shared memory and using either semaphores or messages to pass a “token” to inform the other

process that data was available in shared memory.

what to do:

create server for data communication between process

send data to server

retrieving data from server

craete shared memory segments to transfer large amount of data

Reference: beginners Linux programming :Chapter14 :Semaphores, Shared Memory, and Message

Queues pg no:599

32. Race conditions using fork, semaphores, Record locking, sleep and pipes

A race condition occurs when multiple processes are trying to do something with shared data and the final outcome depends on the order in which the processes run. The fork function is a lively breeding ground for race conditions, if any of the logic after the fork either explicitly or implicitly depends on whether the parent or child runs first after the fork. In general, we cannot predict which process runs first. Even if we knew which process would run first, what happens after that process starts running depends on the system load and the kernel's scheduling algorithm. Demonstrate Race conditions with fork, multiple processes updating the same file without using any form of locking, semaphores, Record locking, Reliable implementation of sleep, avoiding the race condition in the earlier implementation and pipes.

a) A race condition occurs when multiple processes are trying to do something with shared data and the final outcome depends on the order in which the processes run. The fork function is a lively breeding ground for race conditions The goal in this program is to allow the kernel to switch between the two processes as often as possible to demonstrate the race condition. To avoid race conditions and to avoid polling there are three ways to do let a parent and child synchronize

1. We require that each process tell the other when it has finished its initial set of operations, and that each wait for the other to complete, before heading off on its own

2. Some form of signaling is required between multiple processes. Show how signals can be used to synchronize a parent and child.

3. Various forms of interprocess communication (IPC) can also be used. Using two pipes for parentchild synchronization

Write UNIX system programs to demonstrate the above scenarios. b) Write a unix system program for the Implementation of Sequence-number

increment using Seq# in file, fcntl locking, avoiding race conditions and deadlocks Reference: Advanced Programming in the UNIX Environment: Second Edition by W. Richard

Stevens, Stephen A. Rago, Publisher: Addison Wesley Professional/ Pearson, Chapters: 8, 10, 15

33. ls, more, internet Day Time Server, Chef/Cook server

The PF_LOCAL Chef/Cook server is comprised of two programs:

Page 26: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

"chef," the server, which creates a named socket called "recipe" and writes the recipe

to any clients who request it. The recipe is a collection of variable-length NULL-

terminated strings.

"cook," the client, which connects to the named socket called "recipe" and reads the

recipe from the server. It displays the recipe to standard output as it reads it, and then

terminates.

The chef server process runs in the background. Any client cook processes that connect to the

server cause the server to fork a duplicate server to handle the recipe transfer, allowing the

original server to accept other incoming connections.

The internet Day Time Server allows you to connect to port 13 of any Internet host in the world

and find out the "remote" time of day. It allows three kinds of Internet address:

If you enter "s", it automatically means the local host.

If you enter something that starts with a digit, it's assumed to be an A.B.C.D format IP

address, and is converted into a 32-bit IP address by software.

If you enter a string, it's assumed to be a symbolic host name, and is converted into a

32-bit IP address by software.

a) Write a system program to demonstrate UNIX Domain Sockets using socketpair( ) by building echo client server, current client server, chef/cook applications.

Here's some sample output from the chef/cook example:

$ ./chef & ...run the server in the background. [1] 5684

$ ./cook ...run a client--display the recipe. spam, spam, spam, spam, spam, and spam.

$ ./cook ...run another client--display the recipe.

spam, spam, spam, spam, spam, and spam.

$ kill %1 ...kill the server. [1] Terminated chef $ _

b) Implement TCP/IPv4 version of the echo client server. c) Write a UNIX system program, aupls.c ( like ls) with the –R option first lists the path

to a directory and all of the entries at that level, including directories, and then for each directory does the same thing, recursively

d) Implement more command. Reference: Advanced Unix Programming, Second Edition by Mac J. Rochkind

Publisher: Addison Wesley Professional/ Pearson, Chapters: 3 Projects:

Linux for Programmers and Users by Graham Glass, King Ables

Publisher: Pearson, Chapters: 12

Page 27: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

34. Reverse, Monitor and process topology Utility using Pipes, FIFOS and Message Queues,

Shared Memory, Sockets and pthreads.

a) Develop the reverse utility that works by performing two passes over its input. During the first pass, it notes the starting offset of each line in the file and stores this information in an array. During the second pass, it jumps to the start of each line in reverse order, copying it from the original input file to its standard output.

If no file name is specified on the command line, reverse reads from its standard input during the first pass and copies it into a temporary file for the second pass. When the program is finished, the temporary file is removed.

b) Develop the monitor utility that continually scans the specified files and directories for modifications. It uses the stat () system call to obtain status information about named files, including their type and last modification time, and uses the readdir () system call to scan directories. It maintains a status table called stats, which holds the following information about each file that it finds:

o the name of the file o the status information obtained by the stat () o a record of whether the file was present during the present scan and

the previous scan During a scan, monitor processes each file as follows: o If the file isn't currently in the scan table, it's added and the message

"ADDED" is displayed. o If the file is already in the scan table and has been modified since the last scan,

the message "CHANGED" is displayed.

At the end of a scan, all entries that were present during the previous scan but not during the current scan are removed from the table and the message "DELETED" is displayed.

c) Write a UNIX system program that protects a critical region of code from a specific signal.

d) Write a program that creates a chain and fan of n processes, where n is a command-line argument.

e) Creates a binary tree of process

35. Implementation of Fileserver with pipes, FIFOS and Message Queues, Shared Memory,

sockets and pthreads.

Implementation of Fileserver: a client-server application in which the client sends the server a pathname and the server returns the contents of that file to the client using two pipes and other Interprocess communications —FIFOS, Message Queues, Shared Memory. a) Implementation of Fileserver using one System V message queue, multiple clients

with deadlock detection and avoidance by spawn itself when queue is full, creation of new queue and signal handling

b) Implementation of Fileserver using FIFOs, stand-alone iterative server, multiple clients.

c) Implementation of Fileserver using pipes/FIFOs, stand-alone concurrent server, multiple clients.

d) Implementation of Fileserver using pipes/FIFOs, stand-alone iterative/concurrent server, multiple clients by avoiding denial-of service (DoS attack). If a misbehaving client created a client FIFO and sent a request to the server, but did not open its

Page 28: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

FIFO, then the server’s attempt to open the client FIFO would block and other client’s requests would be indefinitely delayed. (If done maliciously, this would constitute a denial-of-service attack.) Devise a scheme to deal with this problem.

e) Implementation of Fileserver using pipe / FIFO: builds records on top of byte stream

f) Implementation of Fileserver using one System V message queue per client, multiple clients

g) Implementation of Fileserver using one System V message queue, multiple clients with deadlock detection and avoidance by spawn itself when queue is full, creation of new queue and signal handling

h) Write a program to determine the system limits on System V message queues i) Write a UNIX system program that shows how a daemon can catch SIGHUP and

reread its configuration file

36. Sequence-number increment Problem using shared memory, Memory Mapping,

Sockets, mutex locks, File Locking, condition variables, semaphores and pthreads.

a) Implementation of Sequence-number increment Problem: one or more threads or

processes increment a shared sequence number. Sometimes the sequence number is

in a shared file, and sometimes it is in shared memory using Memory Mapping, Sockets

mutex locks, File Locking, condition variables and semaphores.

b) Write a Unix system program for Implementation of Sequence-number-increment problem Such that parent and child both increment the same global stored in memory

c) Write a unix system program for the Implementation of Sequence-number increment using Seq# in mmap shared memory, Posix named semaphore locking

d) Write a program for Displaying and modifying POSIX Shared Memory status information

e) Write a unix system program to demonstrate that a shared memory object can be memory mapped starting at different addresses in different processes.

f) Write a unix system program for the Implementation of Sequence-number using Seq# in file, no locking

g) Write a unix system program for the Implementation of Sequence-number increment using Seq# in file, fcntl locking, avoiding race conditions

h) Write a test program that illustrates your system's behavior when a process is blocked trying to write-lock a range of a file and additional read-lock requests are made. Is the process requesting a write lock starved by the processes read-locking the file?

37. Implementation of Producer-consumer problem using using pthreads, condition

variables, mutex, semaphores, Pipes, FIFOS and Message Queues, Shared Memory and

Sockets.

a) Implementation of Producer-consumer: one or more threads or processes (producers) place data into a shared buffer, and one or more threads or processes (consumers) operate on the data in the shared buffer using pthreads, condition variables, mutex, semaphores, Pipes, FIFOS and Message Queues, Shared Memory and Sockets.

b) Demonstrate deadlock in the producer-consumer problem c) Write a system program to demonstrates file locking using fcntl( ) system call for

Page 29: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

lockdemo.c, which waits for the user to hit return, then locks its own source, waits for another return, then unlocks it.

d) Write a program lockdemo.c, which waits for the user to hit return, then locks its own source, waits for another return, then unlocks it. By running this program in two (or more) windows, see how programs interact while waiting for locks.

38. Building a Simple Shell Develop shell from the bottom up, which explores the intricacies of process creation,

termination, identification and the correct handling of signals. Sub programs handle foreground and background processes, pipelines, I/O redirection, shared Memory, Threads, Semaphores, Domain Sockets, process groups, sessions and controlling terminals.

A shell is a process that does command-line interpretation. In other words, a shell reads a command line from standard input and executes the command corresponding to the input line. In the simplest case, the shell reads a command and forks a child to execute the command. The parent then waits for the child to complete before reading in another command. A real shell handles process pipelines and redirection, as well as foreground process groups, background process groups and signals.

39. UNIX Utilities Token ring Simulator using pipes, Dining Philosophers Problem using Pthreads, Mutex, condition variables, Monitors and Semaphores. a) Write a unix system program to solve and demonstrate deadlock in the Dining

Philosophers Problem using Pthreads

Mutex

Semaphores

Condition Variables

b) The Process Ring Simulator simulates a program consisting of pipe, dup2, close, fork, read, write, and print instructions. Write a program that creates a ring of three processes connected by pipes. The first process should prompt the user for a string and then send it to the second process. The second process should reverse the string and send it to the third process. The third process should convert the string to uppercase and send it back to the first process. When the first process gets the processed string, it should display it to the terminal. When this is done, all three processes should terminate. Here's an illustration of the process ring:

Here's an example of the program in action:

Page 30: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

$ ring ...run the program. Please enter a string: ole Processed string is: ELO $ _

40. Traversing Directories in BFS and DFS a) Traversing Directories

Develop programs to traverse directory trees in depth-first and breadth-first orders. Depth-first searches explore each branch of a tree to its leaves before looking at other branches. Breadth-first searches explore all the nodes at a given level before descending lower in the tree. For the file system tree in Figure, depth-first ordering visits the nodes in the following order. /

dirC

my3.dat

dirA

dirB

my1.dat

my1.dat

my2.dat The indentation of the filenames above shows the level in the file system tree. Depth-first search is naturally recursive, as indicated by the following pseudocode.

depthfirst(root) {

for each node at or below

root visit node; if node is a

directory

depthfirst(node); }

For the file system tree in Figure, breadth-first order visits the nodes in the following order.

/ /dirC /dirA /dirC/my3.dat /dirA/dirB /dirA/my1.dat

Page 31: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

/dirA/my2.dat /dirA/dirB/my1.dat

Breadth-first search can be implemented with a queue. As the program encounters each directory node at a particular level, it enqueues the complete pathname for later examination. The following pseudocode assumes the existence of a queue. The enqueue operation puts a node at the end of the queue, and the dequeue operation removes a node from the front of the queue. breadthfirst(root){

enqueue(root);

while (queue is not empty) { dequeue(&next); for each node directly below next:

visit the node if node is a directory

enqueue(node) }

} b) Write a UNIX system program, aupls.c ( like ls) with the –R option first lists the path

to a directory and all of the entries at that level, including directories, and then for each directory does the same thing, recursively

c) Write a UNIX system program that Recursively descend a directory hierarchy, counting file types

d) Design a file-copying program named filecopy using ordinary pipes.This program will be passed two parameters: the name of the file to be copied and the name of the copied file. The program will then create an ordinary pipe and write the contents of the file to be copied to the pipe. The child process will read this file from the pipe and write it to the destination file. For example, if we invoke the program as follows: $filecopy input.txt copy.txt The file input.txt will be written to the pipe. The child process will read the contents of this file and write it to the destination file copy.txt.

e) Write a Unix system program for Implementation of Sequence-number-increment Such that parent and child both increment the same global stored in memory.

f) Write a unix system program for the Implementation of Sequence-number increment using Seq# in mmap shared memory, Posix named semaphore locking

41. Multithreaded Prime, Sorting and Sudoku Solution Validator a) Multithreaded Sorting Application: Implement any 3 parallel sorting algorithms. b) Multithreaded Sudoku Solution Validator: Implement parallel version of Sudoku and

Sudoku Solution Validator. c) Multithreaded Prime number generator using sieve algorithm, parallel primality test d) Multithreaded file server using two pipes. e) Use unnamed semaphores to solve the synchronization problem in sending

messages 42. Parallel Monte Carlo Pi

a) An interesting way of calculating pi is to use a technique known as Monte Carlo, which involves randomization. Write a multithreaded version of this algorithm that creates a separate thread to generate a number of random points. The thread will count the number of points that occur within the circle and store that result in a

Page 32: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

global variable. When this thread has exited, the parent thread will calculate and output the estimated value of pi. It is worth experimenting with the number of random points generated. As a general rule, the greater the number of points, the closer the approximation to pi.

b) Instead of using a separate thread to generate random points, use OpenMP to parallelize the generation of points. Be careful not to place the calculcation of pi in the parallel region, since you want to calculate pi only once.

c) Modify above program so that you create several threads, each of which generates random points and determines if the points fall within the circle. Each thread will have to update the global count of all points that fall within the circle. Protect against race conditions on updates to the shared global variable by using mutex locks.

d) Use unnamed semaphores to solve the synchronization problem in sending messages

e) A barrier is a tool for synchronizing the activity of a number of threads. When a thread reaches a barrier point, it cannot proceed until all other threads have reached this point as well. When the last thread reaches the barrier point, all threads are released and can resume concurrent execution.

Assume that the barrier is initialized to N—the number of threads that must wait at the barrier point: init(N);

Each thread then performs some work until it reaches the barrier point: /* do some work for awhile */

barrier point();

/* do some work for awhile */

construct a barrier that implements the following API using pthreads: • int init(int n)—Initializes the barrier to the specified size. • int barrier point(void)—Identifies the barrier point. All threads are

released from the barrier when the last thread reaches this point. The return value of each function is used to identify error conditions. Each function will return 0 under normal operation and will return −1 if an error occurs. f) Implement a barrier using busy-waiting and a mutex g) Implement a barrier using semaphores

43. Parallel matrix-vector multiplication, estimate pi and Implementation of a barrier

a) Print a greeting from each thread b) Serial matrix-vector multiplication c) Pthreads matrix-vector multiplication d) Buggy attempt to estimate pi with pthreads e) First attempt at using busy-waiting to protect a critical section f) Estimate cost of forking and joining threads g) Second attempt at using busy-waiting to protect a critical section h) Use a mutex to protect the critical section in the pi program i) Try to send messages among the threads j) Use unnamed semaphores to solve the synchronization problem in sending

messages k) Use named semaphores to solve the synchronization problem in sending messages

Page 33: Operating Systems (13CS203) List of Projects A.Y. 2015 ... · Operating Systems (13CS203) List of Projects A.Y. 2015-2016, Even Semester 1. Implementation of a tiny shell to perform

l) Implement a barrier using busy-waiting and a mutex m) Implement a barrier using semaphores n) Implement a barrier using a condition variable o) Pthreads matrix-vector multiplication program that generates a random matrix and

vector.

44. Pthreads linked list and thread safe tokenize a) A serial linked list program b) A Pthreads linked list program that uses a single mutex to control access to the list. c) Thread-safe random number generator d) Header file for thread-safe random number generator e) A Pthreads linked list program that uses a one mutex for each list node f) A Pthreads linked list program that uses read-write locks g) Pthreads program that attempts to tokenize input text with strtok h) Pthreads program that tokenizes input text with strtok_r