os:lab05
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/lab05?rev=1571865425&do=diff
Differences
This shows you the differences between two versions of the page.
— | os:lab05 [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Return to [[os: | ||
+ | ---- | ||
+ | ====== Operating Systems Course: Lab05 ====== | ||
+ | ===== Laboratory number 05 ===== | ||
+ | |||
+ | |||
+ | ==== Exercise 01: Signals and pipe ==== | ||
+ | Implement the solution of exercise 04 of laboratory 04 ([[os: | ||
+ | |||
+ | That is, implement a C program that generates two children, a producer and a consumer. | ||
+ | The producer child reads from the keyboard some strings, and it transfers them to the consumer. | ||
+ | The consumer child converts the strings into uppercase characters, and it visualizes the strings in standard output. | ||
+ | The transfer of the strings (and synchronization) has to take place through pipes. | ||
+ | |||
+ | **Observation: | ||
+ | The length of the strings transferred through the pipe is variable and not known a priori. | ||
+ | It is therefore appropriate to use some communication mechanism/ | ||
+ | For instance, it is possible to transfer in the pipe the dimension of the string before the string itself, by using a constant number of characters to code this dimension. | ||
+ | |||
+ | |||
+ | ==== Exercise 02: Pipe and synchronization ==== | ||
+ | Since the //read// operation in a pipe is a " | ||
+ | |||
+ | More in detail, using two pipes between two processes, the first process can wait for the second process by reading from the first pipe, and the second process can wait for the first process by reading from the second pipe. | ||
+ | |||
+ | By using this mechanism, implement the following procedure. | ||
+ | The parent process generates a child process. | ||
+ | |||
+ | After the creation, both processes want to send messages on standard output (or on a file) synchronizing so that the messages are (strictly) alternated, for example: | ||
+ | |||
+ | <code txt> | ||
+ | I'm the father (PID=...) | ||
+ | I'm the child (PID=...) | ||
+ | I'm the father (PID=...) | ||
+ | I'm the child (PID=...) | ||
+ | I'm the father (PID=...) | ||
+ | I'm the child (PID=...) | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | Note that you have not to use '' | ||
+ | The parent sends to the child a specific synchronization message to indicate that the execution needs to be terminated. | ||
+ | |||
+ | |||
+ | ==== Exercise 03: Command find ==== | ||
+ | Execute the following operation with the '' | ||
+ | - Print the list of the files in the tree with root ''/'' | ||
+ | - Print the path of all the files with extension " | ||
+ | - Print all the files of your user, of regular type, that contain in the name at least one '' | ||
+ | - Print all the files of your user from the level of depth 3 to the level of depth 5, with a dimension of at least 250 bytes, and with the name of exactly 4 characters. Of these files count the number of characters. Repeat the same operation counting the number of rows. | ||
+ | - Print all the files in the system with an extension of 3 characters, with the name beginning with an '' | ||
+ | - Print the content of all the directories, | ||
+ | - Find all the files with the extension '' | ||
+ | - Modify the permissions of all your files in the first level of the sub-tree of the root of the file system, so that all users other than the owner have no permission. | ||
+ | |||
+ | |||
+ | ==== Exercise 04: Filters ==== | ||
+ | Giving a file of name [[https:// | ||
+ | |||
+ | Using the known filters (commands '' | ||
+ | - The list of the same data ordered by reverse id number (attention to the position of the ids 89499 and 94799) | ||
+ | - The list of the same data ordered by surname | ||
+ | - The list of students who attended in 2011-2012. | ||
+ | - The list of students in computer science (INF1T3) ordered by id number. | ||
+ | - The list of students with an id that terminates with 2 or with 4, and ordered by surname. | ||
+ | - The list of TCL students (TLC1T3), that they still have to attend (i.e., row with string "Da frequentare" | ||
+ | - The list of students which name contains two '' | ||
+ | - The list of students which name contains two '' | ||
+ | - Take only the id numbers from the file, eliminate all the digit equal to 0, substitute all the digit equal to 8 with 1, sort the resulting list and eliminate all the duplicates. | ||
+ | - Perform all the operation of the previous point (point 9), but print only duplicate lines, counting them. | ||
+ | |||
+ | |||
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/lab05?rev=1571865425&do=diff