Operating system exercises, Assignments of Computer science

Operating system exercises to learn well.

Typology: Assignments

2021/2022

Uploaded on 10/09/2022

unknown user
unknown user 🇱🇰

5

(1)

4 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Q1. What is a process? Give an example.
A process is a program in execution.
A process is an instance of a program running in a computer.
Example =
when you want to search something on web then you start a browser. So, this can be
process. Another example of process can be starting your music player to listen to some cool
music of your choice.
Q2. Explain in brief about the different states of the processes.
New State: This is the state when the process is just created. It is the first state of a process.
Ready State: After the creation of the process, when the process is ready for its execution then it
goes in the ready state. In a ready state, the process is ready for its execution by the CPU but it is
waiting for its turn to come. There can be more than one process in the ready state.
Running State: Amongst the process present in the ready state, the CPU chooses one process
amongst them by using some CPU scheduling algorithm. The process will now be executed by the
CPU and it is in the running state.
Waiting: During the execution of the process, the process might require some I/O operation like
writing on file or some more priority process might come. In these situations, the running process will
have to go into the waiting or blocked state and the other process will come for its execution. So, the
process is waiting for something in the waiting state.
Terminated State: After the complete execution of the process, the process comes into the
terminated state and the information related to this process is deleted.
Q3. Differences between;
a) Process creation v/s Process Termination
Process creation
Parent process creates children process, which, in turn create other processes, forming a tree of
processes.
Resource sharing options
Parent and children share all resources.
Children share subset of parent’s resources.
Parent and child share no resources.
pf2

Partial preview of the text

Download Operating system exercises and more Assignments Computer science in PDF only on Docsity!

Q1. What is a process? Give an example.

 A process is a program in execution.  A process is an instance of a program running in a computer. Example =  when you want to search something on web then you start a browser. So, this can be process. Another example of process can be starting your music player to listen to some cool music of your choice.

Q2. Explain in brief about the different states of the processes.

New State: This is the state when the process is just created. It is the first state of a process. Ready State: After the creation of the process, when the process is ready for its execution then it goes in the ready state. In a ready state, the process is ready for its execution by the CPU but it is waiting for its turn to come. There can be more than one process in the ready state. Running State: Amongst the process present in the ready state, the CPU chooses one process amongst them by using some CPU scheduling algorithm. The process will now be executed by the CPU and it is in the running state. Waiting: During the execution of the process, the process might require some I/O operation like writing on file or some more priority process might come. In these situations, the running process will have to go into the waiting or blocked state and the other process will come for its execution. So, the process is waiting for something in the waiting state. Terminated State: After the complete execution of the process, the process comes into the terminated state and the information related to this process is deleted.

Q3. Differences between;

a) Process creation v/s Process Termination

Process creation

Parent process creates children process, which, in turn create other processes, forming a tree of processes.  Resource sharing options  Parent and children share all resources.  Children share subset of parent’s resources.  Parent and child share no resources.

 Execution options  Parent and children execute concurrently.  Parents wait until some or all of its children have terminated.  Address space options  Child process is a duplicate of the parent process (same program and data)  Child process has a new program loaded into it.  UNIX example  fork() system call creates new process.  exec() system call used after a fork() to replace the memory space of the process with a new program.

Process Termination

 Process executes last statement and asks the operating system to terminate it (via exit ).  Exit (or return) status value from child is received by the parents (via wait() )  Process resources are deallocated by operating system.  Parent may terminate execution of children process ( kill() function )  Child has exceeded allocated resources.  Task assigned to child is no longer required.  If parent is exiting  Some operating system do not allow child to continue if its parent terminates.  All children terminated – cascading termination.