UNIX Shell-Advanced Operating Systems-Assignment, Exercises of Computer Science

I am student at Baddi University of Emerging Sciences and Technologies. To help my friends in other universities, I am uploading my assignments of different courses. Its for Advanced Operating Systems course. Other can see if they are searching following: Execute, Command, Pipes, Functionality, Sort, Implement, Unix, Shell, Threading, Library

Typology: Exercises

2011/2012

Uploaded on 08/01/2012

parmitaaaaa
parmitaaaaa 🇮🇳

4.2

(111)

173 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Question No. 1 [10 points]
Explore and find the purpose of the following routines:
Dup()
Dup2()
(a) What is main difference between them?
In UNIX, on the command line, we often use pipes to connect programs so that the standard output
of one program becomes the standard input of the next, For example, the command:
# last | sort will execute the last command and pipes its output to the sort command. The
redirection is done by the command line option “|”.
(b) Can dup and dup2 be used to make such sort of functionality? If yes, how? If no, give
reason(s) why?
Question No. 2 [20 points]
You are required to implement a Unix shell that supports the following commands:
rm
mv
mkdir
rmdir
Please note that you have to provide your own implementation, you are not allowed to use C
function that takes an argument of a Unix command and executes that command.
Question No. 3 [30 points]
Write a C program that creates two threads using the POSIX threading library. In the main program,
create a file ‘data.txt’. First thread writes some numeric value to the file along with the system time,
the second thread reads the data from the ‘data.txt’ file and displays the following information on
standard output, i.e., computer screen.
Numeric Value Time when Value was written to the File Time when Value was Read by the Thread
You are required to use synchronization primitives provided by the UNIX OS to ensure consistency
and serial access to the file, i.e., a thread can only read data from the file, if the other thread has
written new data to the file, and a file is only accessed by a thread if the other thread is not using
the file. The thread responsible for writing data to the file writes to the file after 500 ms. The
program terminates when Ctrl+C is hit by the user.
Question No. 4 [20 points]
a. What are the motivations to the design development of Mach Kernel foundation
development?
b. Differentiate between the Task and Thread in Mach design.
docsity.com
pf2

Partial preview of the text

Download UNIX Shell-Advanced Operating Systems-Assignment and more Exercises Computer Science in PDF only on Docsity!

Question No. 1 [10 points] Explore and find the purpose of the following routines: Dup() Dup2()

(a) What is main difference between them?

In UNIX, on the command line, we often use pipes to connect programs so that the standard output of one program becomes the standard input of the next, For example, the command:

# last | sort will execute the last command and pipes its output to the sort command. The

redirection is done by the command line option “|”.

(b) Can dup and dup2 be used to make such sort of functionality? If yes, how? If no, give reason(s) why?

Question No. 2 [20 points] You are required to implement a Unix shell that supports the following commands:  rm  mv  mkdir  rmdir

Please note that you have to provide your own implementation, you are not allowed to use C function that takes an argument of a Unix command and executes that command.

Question No. 3 [30 points] Write a C program that creates two threads using the POSIX threading library. In the main program, create a file ‘data.txt’. First thread writes some numeric value to the file along with the system time, the second thread reads the data from the ‘data.txt’ file and displays the following information on standard output, i.e., computer screen.

Numeric Value Time when Value was written to the File Time when Value was Read by the Thread

You are required to use synchronization primitives provided by the UNIX OS to ensure consistency and serial access to the file, i.e., a thread can only read data from the file, if the other thread has written new data to the file, and a file is only accessed by a thread if the other thread is not using the file. The thread responsible for writing data to the file writes to the file after 500 ms. The program terminates when Ctrl+C is hit by the user.

Question No. 4 [20 points]

a. What are the motivations to the design development of Mach Kernel foundation development? b. Differentiate between the Task and Thread in Mach design.

docsity.com

c. What are the basic abstractions that the Mach kernel supports?

Question No. 5 [20 Points]

Explain the process of compiling the Linux Kernel; you are required to explain

different steps involved and the purpose of each step along with required

commands.

docsity.com