Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that will display a prompt to the user as following where the user can enter their commands. On this prompt it will

  1. Write a program that will display a prompt to the user as following where the user can enter their commands.

    On this prompt it will accept regular Linux commands from the user e.g.

    This command then will be executed by creating a child process and running the command in that child process. However, the output will not be displayed immediately to the user; rather, will be stored in a named pipe. Once, the output is ready (child process will indicate to the parent process which is your shell (you are free to pick your logic here)), the parent process will indicate the user that the output of the process is ready, and if user agrees, it will be displayed on the screen.

--SHELL--YOURID>>

--SHELL--YOURID>> ls -l

The user will have two choices to run a command: foreground and background. In case of foreground request, when user will submit a command, the prompt will not be returned to the user. It will be returned only when the output is ready, as mentioned above. Below is an example output. The FG prefix indicates that command should be executed in foreground:

In case of background request, when user will submit a command, a message indicating the submission of the command will be displayed and the prompt will be returned to the user for further commands. When the output is ready, the user will be indicated of that and if agreed the output will be delayed. Below is an example output. The BG prefix indicates that command should be executed in foreground:

The key requirements in this program are: running the request in child process and implementing the FG/BG feature. Additional algorithmic details are not significant, and students are free to pick their logic.

  • #1-A: Write/type your source code in your submission file/document. Also, submit the .c file separately.

  • #1-B: In your submission file/document, add a screenshot which displays: o the execution of your program with the FG case o the execution of your program with the BG case

  • Question 2: Simulating a Multi Level Scheduler

    Write a C program that will simulate the operation of a kernel with two-level-scheduler (short term and long term) using the Pthread library. The main program (kernel) will have two threads, each representing one of the two schedulers (implemented in code as two separate functions). There will be two Queues (use the Linux data structures from chapter 1): ready queue and new queue. Also, implement a struct with two elements: PID (unique ID of process) and Time (total execution time of process).

    At the start of the program, populate the new Queue with 100 processes. For each process, auto increment (staring from 1) the PID and randomly select Time (in the range 1-30). Then create the two threads for the two schedulers. Now invoke the long-term scheduler.

--SHELL--YOURID>> FG ls -l ....working on request..... ....output is ready. Display it now [Y/N]>>Y Response of command --SHELL-YOURID>>

--SHELL--YOURID>> BG ls -l ....request submitted, returning prompt..... --SHELL-YOURID>> ....output for BG ls -l is ready. Display it now [Y/N]>>Y Response of command --SHELL-YOURID>>

Long-term scheduler method will dequeue an element (process) from the new queue and enqueu into the ready queue. However, the ready queue has maximum length 5. In this method, display suitable logging message to the screen i.e. start, action, stop. Long-term scheduler will pass the control to short-term scheduler.

The short-term scheduler method will dequeue an element (process) from the ready queue, reduce its time by two, enqueu it to the ready queue. It will repeat this process five times and then pass the control to the long-term scheduler. If the Time of a certain element (process) reaches zero then it will be permanently removed from the ready queue. Also, in this method, display suitable logging message to the screen i.e. start, action, stop.

The program will end when all the elements have zero Time left.

  • #2-A: Write/type your source code in your submission file/document. Also, submit the .c file separately.

  • #1-B: In your submission file/document, add a screenshot which displays the execution of your program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

Networking is a two-way street. Discuss this statement.

Answered: 1 week ago