operating system part 3
CS308 - Operating System Assignment III (10 points)
Part I (3 points): While working with computers, you may need to create a file(s) and a folder(s). You can -in each folder- find, create, and remove a file(s) and a sub-folder(s). You can also -in each sub-folder- find, create, and remove a file(s) and a sub- folder(s), and so on. A folder, in the field of operating systems, is referred to as a directory. Sub-folder means folder within a folder. Such a structure of directories, sub-directories, and files is known as a file system (as we will discuss more in unit 6). In this part of the assignment, we will start a discussion on some Linux commands to navigate within a file system, and discuss more commands in assignment4.
Open the Ubuntu virtual machine you installed. After your log in using the credentials, open a terminal, and test the following commands:
Any Linux command is structured as follows: The command [list of attributes/options as input(s) to the command]
Command1: ls Very similar to when you double click on a folder (e.g., Downloads) to see the content (files and sub-folder), “ls” - which stands for List- is used to display information about the files and sub-directories in the current directory. Do some search on the internet to read about the following “ls” options. Type the command in the terminal (one by one), click enter to run the command, take a screenshot of the output, and then explain the purpose (the different parameters/info of the output) of the command in your own words - Before you move to the next command.
The ls commands we would like to try are: ls ls -a ls -l
Command2: pwd After you open folders and sub-folders, you may want to know where you are within the filesystem (e.g., /Downloads/Assignments/Assignment3). “pwd” -which stands for Print Working Directory- is used to display the path of the working directory (where are you in the system). Type the command in the terminal, click enter to run, and take a screenshot of the output. Command3: cd Using the Windows graphical interface, you can double-click to open a folder or click the back button to return to the parent folder. Through the terminal, we have an essential command called “cd” -which stands for the Change Directory. After you run the ls command, you will find the different file(s) and sub-folder(s). Let us assume you find a sub-folder named Folder_M (this is just a name, so try one of the folders you find after your run ls). To open Folder_M, try:
cd Folder_M
To return to the parent directory, try:
cd ..
For each of these two cd commands: Type the command in the terminal, run the “pwd” command, then the “ls” command, and take a screenshot of the output.
Part II (7 points – 3.5 points per problem): After our discussion on Deadlocks, we want to check some classical problems. For each of the following problems:
Step1: Think of a pseudo-code on how you can solve such a problem using one of the synchronization techniques (e.g., locks, semaphores). Step2: Do some search on the internet on how such a problem was solved and then adjust/update your pseudo- code accordingly - use your own words to develop the pseudo-code. Step3: Add your clarifying comments on the final pseudo-code explaining the logic/steps and the variables in detail. *Doing online/offline research to understand any topic is an essential task – you must not copy; you should learn from the different external resources and develop -based on what you learned- an answer by yourself
Problem 1: Sleeping Barber (3.5 points) The Sleeping barber is a classical synchronization problem. There is one barber in the barbershop, one barber chair, and n chairs available for waiting customers. If there are no customers, the barber sits down in the barber chair and takes a nap. An arriving customer must first wake the barber, and the customer takes the barber chair. Subsequent arriving customer takes a waiting chair if any is empty or leaves if all chairs are full. In this case, we are synchronizing the barber and customers. Problem 2: Dining Philosophers (3.5 points) The Dining Philosophers is a classic synchronization problem. There is a circular table with five plates and between each plate, there is a single chopstick (fork). In the middle of the table, there is a bowl of delicious spaghetti. There are five philosophers who spend most of their time thinking, but also get hungry and need to eat for some time to think more. A philosopher must pick up the two chopsticks to the left and right of his plate in order to eat. Philosophers may pick up and put down their chopsticks in either order, where two philosophers cannot use a single chopstick at the same time.
Dining table with plates and forks
Submission:
1. This is an individual assignment -- Cheating/plagiarism will be checked and receive a zero.
2. Submit only ONE PDF file to the folder titled Assignment 3 under the D2L Assignments tab; your file is structured as follows:
a. Part I – 3 points. b. The final pseudo-code of Part II - Problem 1 (with your own clarifying comments) – 2.5 points. c. The final pseudo-code of Part II - Problem 2 (with your own clarifying comments) – 2.5 points. d. The online articles/resources you used to answer each problem – 2 points.
* you must submit one PDF file, don’t submit a zip file
3. Do not submit handwritten answers (any handwritten answer will receive zero) 4. Submissions with copied answers from online/offline resources will receive zero. 5. The assignment is due November 11th – at 11:59 pm. You can submit your assignment within 24 hours after
this due date to be graded out of 50% of the assignment’s grade. After this grace period, your late submission will not be accepted.