os_ex4

1
Operating Systems (04JEZOQ) LAB 4 - Processes Exercise 1: Implement a scheme reader / writers. Write a C program able to run 5 readers and 3 writer processes. Each editor writes the following characters in a text file: 1. The editor writes a character 'A' 2. The editor writes the two characters 'BB' 3. The editor writes the three characters 'CCC' Each reader reads from the text file and displays the characters on screen. Exercise 2: Write a C program that implements a train station. The station has only 1 input rail and 4 exit rails, called LO (1), LO (2), LO (3) and LO (4). The program defines 10 train processes. Each train T rails on its own railway LE(T) and enters into the station using the input rail and it assigned to an exit rail. A train cannot enter the station if the station is busy (serving some other train request) or if the exit route that it has requested to continue its journey is not free. Trains arrive at the station entrance with random time intervals of x seconds (0 < x < T). The train station assigns a way out rail to each train randomly.

Upload: george-balan

Post on 15-Dec-2015

2 views

Category:

Documents


1 download

DESCRIPTION

Operating Systems course exercises

TRANSCRIPT

Page 1: OS_ex4

Operating Systems (04JEZOQ) LAB 4 - Processes

Exercise 1: Implement a scheme reader / writers. Write a C program able to run 5 readers and 3 writer processes. Each editor writes the following characters in a text file:

1. The editor writes a character 'A' 2. The editor writes the two characters 'BB' 3. The editor writes the three characters 'CCC'

Each reader reads from the text file and displays the characters on screen.

Exercise 2: Write a C program that implements a train station. The station has only 1 input rail and 4 exit rails, called LO (1), LO (2), LO (3) and LO (4).

The program defines 10 train processes. Each train T rails on its own railway LE(T) and enters into the station using the input rail and it assigned to an exit rail. A train cannot enter the station if the station is busy (serving some other train request) or if the exit route that it has requested to continue its journey is not free.

Trains arrive at the station entrance with random time intervals of x seconds (0 < x < T). The train station assigns a way out rail to each train randomly.