os:lab08
Return to Home page
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/lab08?do=diff&rev2%5B0%5D=1575458236&rev2%5B1%5D=1575529002&difftype=sidebyside
Differences
This shows you the differences between two versions of the page.
— | os:lab08 [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Return to [[os: | ||
+ | ---- | ||
+ | ====== Operating Systems Course: Lab08 ====== | ||
+ | ===== Laboratory number 08 ===== | ||
+ | |||
+ | |||
+ | ==== Exercise 01: Access to critical sections ==== | ||
+ | Suppose to have in substitution of the function '' | ||
+ | |||
+ | <code c> | ||
+ | int atomicIncrement (int *var) { | ||
+ | int tmp = *var; | ||
+ | *var = tmp + 1; | ||
+ | return (tmp); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Use this function to write the functions '' | ||
+ | |||
+ | **Suggestion: | ||
+ | Use two global variables '' | ||
+ | The first indicates the reservation order to enter the //critical section//, and the second manages the turn for accessing the critical section.\\ | ||
+ | Manage these variables through the functions '' | ||
+ | |||
+ | |||
+ | ==== Exercise 02-04: Precedence graphs with semaphores ==== | ||
+ | Given the following // | ||
+ | |||
+ | <code txt> | ||
+ | | ||
+ | / | \ ^ | ||
+ | / | ||
+ | B C D | | ||
+ | | / \ | ||
+ | | / | ||
+ | | E F | | | ||
+ | | \ / | ||
+ | | \ / | ||
+ | | G H | | ||
+ | | ||
+ | \ | / | | ||
+ | | ||
+ | </ | ||
+ | in which each vertex corresponds to an independent task (a process or a thread).\\ | ||
+ | Implement it with the following ways, and using the minimum number of semaphores. | ||
+ | |||
+ | === Exercise 02 === | ||
+ | Each task corresponds to a process.\\ | ||
+ | Each process is (re-)created and destroyed at each iteration of the principal cycle.\\ | ||
+ | Semaphores are implemented by means of pipes. | ||
+ | |||
+ | === Exercise 03 === | ||
+ | Each task corresponds to a thread.\\ | ||
+ | Each thread is (re-)created and destroyed at each iteration of the principal cycle.\\ | ||
+ | Semaphores are implemented by means of the POSIX library, and types/ | ||
+ | |||
+ | === Exercise 04 === | ||
+ | Each task corresponds to a thread.\\ | ||
+ | Threads are all **cyclic** and they are created and destroyed only one time in the principal cycle.\\ | ||
+ | Semaphores are implemented by means of the POSIX library, and types/ | ||
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/lab08?do=diff&rev2%5B0%5D=1575458236&rev2%5B1%5D=1575529002&difftype=sidebyside
/web/htdocs/www.skenz.it/home/data/pages/os/lab08.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1