Table of Contents

Return to Operationg Systems home


Operating Systems Course: Lab11

Laboratory number 11 (pseudo-exam test)

Exercise 01

Implements with the semaphore primitives the prologue and the epilogue of 4 functions A, B, C, and D, so that the processes that call them respect the following path expression:

path ( A+B; {C}; D ) end

The meaning of this path expression is that the set of processes can:

If, for instance, the first of all the functions called is function D, the process that called it, it is blocked until other processes have called A or B, and then C.

The path expression is cyclic, i.e., when function D is executed, functions A or B (etc.) can be performed again, without waiting.

Suggestion
Refer to the solution of Readers & Writers.

Exercise 02

Illustrate the characteristics, differences and typical use of the system calls fork, execve, and system.

Exercise 03

Realize a bash script that receives two parameters:

The script must recognize all the files of the specified user that are in the directory and its subdirectories, and that contain (at least) a row that begins with the string “***Da modificare”.

In those files you need to:

Check the correct passage of the parameters.

Exercise 04

Write a multi-thread program that sorts a vector of integer numbers using the algorithm merge-sort and using concurrency instead of recursion.

Each thread, starting from the initial one must:

Note that the termination condition occurs when a thread receives a vector of dimension n=1.

The vector and its dimension can be read from the keyboard, from a file, or generated randomly.

Exercise 05

Given the following processes, with the relative arrival times and their duration:

P1 0 11
P2 2  9
P3 4  7
P4 6  5
P5 8  3

Report the Gantt charts and calculate the average waiting times for the algorithms FCFS, SJF and SRTF.

Exercise 06

With reference to deadlock prevention through the hierarchical use of resources, describe the technique and demonstrate that it cannot lead to deadlock.