Course Hero Logo

OS-Homework2 (785095034) (1).docx - Ex. 2.1 | (15pts) Draw...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 5 out of 8 pages.

Ex. 2.1 | (15pts) Draw schedule diagrams of the following task set for Round-Robin, First-in-first-out(FIFO), and Shortest job first (SJF), respectively. The task set, (arrival time, execution time): T1(1, 10),T2(2, 4), T3(3, 1), T4(4, 6).Time quantum for Round-Robin is 1 time unit. (5pts for each diagram).Solution :ProcessArrival TimeExecution TimeT1110T224T331T446
Ex. 2.2 | (15pts) The following shows three different ways a process can be created.A human user explicitly commands the OS to run a program by double-clicking the program icon ortyping a command.A currently running process creates a sub-process (also known as a child process) prompted by anexternal event (a human user's request, an event caused by another process).A currently running process creates a child process explicitly executing an instruction such as fork().The third case, in which a currently running process creates a new process, in general covers the firsttwo cases. Explain why.
On Unix-like operating systems, fork() is the main technique for creating new processes. This functioncreates a new copy called the child out of the original process, that is called the parent. When theparent process closes or crashes for some reason, it also kills the child process. The child process and theparent process run in separate memory spaces. At the time of fork() both memory spaces have the samecontent.To keep track of all processes, the operating system assigns each one an unique id. And for that, fork()doesn’t take any parameter and return an int value as following:a)Zero value: for child process (the process created).b)Positive value: for parent process.c)Negative value: for error.The child process is an exact duplicate of the parent process except for the following points:1.The child has its own unique process ID, and this PID does not match the ID of any existing processgroup or session.2.The child's parent process ID is the same as the parent's process ID.3.The child does not inherit its parent's memory locks.4.Process resource utilizations and CPU time counters are reset to zero in the child.5.The child's set of pending signals is initially empty.6.The child does not inherit semaphore adjustments from its parent.7.The child does not inherit process-associated record locks from its parent. On the other hand, it doesinherit open file description locks.8.The child does not inherit timers from its parent.9.The child does not inherit outstanding asynchronous I/O operations from its parent, nor does itinherit any asynchronous I/O contexts from its parent.In third case, fork() is used to create a child process which runs with the parent process that created it.1.The fork() command can be seen as a command that is executed by the user either by doubleclicking the icon or by typing a command and hence we can say that it covers the first case ofcreating the process which is creating a process by typing a command.2.The fork() command causes an event of creation of child process by the parent process. So, it coversthe second case of creating a process which is an event caused by another process.Hence, we can say that the third case of currently running process creating a child process explicitlybyexecuting an instruction such as fork() covers the first two cases.
Ex. 2.3 | (15pts) Write a small program that uses fork() and exec() to run the ls command.
if ( r < 0 )

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 8 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
professor_unknown
Tags
Exit

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture