Operating systems
Exam 2021-22 - 1st call
MUKHAMMADBOBUR HOMIDOV
U10106
Started on
Thursday, 4 November 2021, 8:56 AM
Completed on
Thursday, 4 November 2021, 10:26 AM
Time taken
1 hour 30 mins
Grade
10.00
out of 27.00 (
37
%)
Question
1
Complete
Mark 4.00 out of 6.00
1. Present briefly what is a deadlock.
2. List the four necessary conditions characterizing the deadlock.
3. Explain why are they needed.
1. Deadlock is state in which each member of a group waits for another member including itself to
take action, such as sending a message or commonly releasing a lock.
2.
1) mutual exclusion
2) hold and wait
3) no preemption
4) circular wait
3. First condition can be held by only one process at a time.
Second condition can hold one process at a time and another at same time
In third conditon, recourses cannot be preempted
Fourth condition must exist a set processes [p1 p2 ... p(n)] such that p1 is waiting for p2, p2 for p3
and so on
Comment:
11/20/21 8:46 AM
Pagina 1 di 3
Question
2
Complete
Mark 6.00 out of 6.00
Write the commands required on Linux to perform the following actions:
log-in as default user
create a new user whose name is equal to your student ID (e.g., user "su123456")
create a file named "file1.txt" in a subfolder whose name is equal to your student ID (e.g.,
folder "~/su123456")
protect the new folder in a way that:
only the new user can read and write in that folder
all the other users can only read the folder
change the current user and log-in as the new user
as the new user, show the content of the file on screen
1) The su command (switch user) is used to run a command as a default user
Enter the following: su-h
To switch the logged -in user in this terminal window, enter the following su-I [other_user]
2) Log in as a root
Use the command useradd "name of the user (for example, su10000)
USe su plus the nmae of the user you just added to log on
"Exit" will log you out
3) Create an empty text file with touch command
touch filename.txt
4) sudo chmod -R ugo+rw /DATA/SHARE
(r) + (w) for the new user
(r) for all the other user
5) Command su- (switch user)
6) Use the "pg" command
"Cat" command
Comment:
11/20/21 8:46 AM
Pagina 2 di 3
Question
3
Complete
Mark 0.00 out of 15.00
1) Write a program in either Python or C++ that:
Creates one child processes, which calculates and prints on screen the list of prime numbers
(e.g., 2, 3, 5, 7, 11, etc). This process will terminate after 10 seconds, printing on screen the
message "The process found N prime numbers in 10 seconds." where "N" is the number of
prime found.
The main process has to wait for the child to terminate, hence it terminates as well .
2) Write the command that you would use, from the command line, to kill the above program in
case, e.g., for a bug, it does not terminate. NOTE: remember that the program includes two
processes.
#include
#include
#include
#include
using namespace std;
int main{}
pid_t pid;
cout <<"Starting root process with PID"<
pid = fork()
cout << endl;
Comment:
11/20/21 8:46 AM
Pagina 3 di 3