User Tools

Site Tools


os:lab11
Return to Home page

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:

  • call function A or function B in mutual exclusion (i.e., a process waits if the function is used by another process)
  • then, it can call function C (that can be executed concurrently by all the processes)
  • finally, it can call function D.

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, it can be performed again, without waiting, functions A or B etc.

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 name of a user of the system
  • the name of a directory.

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:

  • delete this row
  • append to the name of the file the string “_mod”.

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:

  • receive a vector to sort of dimension n
  • subdivide the vector in two parts of dimension n/2
  • activate a thread on each part of the vector
  • wait for the termination of both threads
  • merge the two received parts of dimension n/2 and already sorted, by performing a merge, and generating a single sorted vector of dimension n.

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.


If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/lab11
/web/htdocs/www.skenz.it/home/data/pages/os/lab11.txt · Last modified: 2020/01/16 09:13 by zioskenz

Privacy Policy