0% found this document useful (0 votes)
33 views

Os 2

A process is an executing program that consists of code, data, and resources. The operating system maintains process information in a process control block and switches between processes using context switching. The process scheduler selects which process runs on the CPU based on scheduling policies and algorithms to maximize CPU utilization and minimize wait times.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Os 2

A process is an executing program that consists of code, data, and resources. The operating system maintains process information in a process control block and switches between processes using context switching. The process scheduler selects which process runs on the CPU based on scheduling policies and algorithms to maximize CPU utilization and minimize wait times.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. **Process**: A process is an executing instance of a program.

It consists of the program


code, data, and resources (such as CPU time, memory space, files, and I/O devices) allocated
by the operating system. The four components of a process are:

- **Program**: The code to be executed.


- **Data**: Variables and data structures required by the program.
- **Process Control Block (PCB)**: A data structure maintained by the operating system to
manage the process.
- **Execution Context**: Information needed to resume the process, such as the program
counter, CPU registers, and stack pointer.

2. **Process State Diagram**:

![Process State
Diagram](https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/State_diagram_of_a_pro
cess.png/550px-State_diagram_of_a_process.png)

- **New**: The process is being created.


- **Ready**: The process is waiting to be assigned to a processor.
- **Running**: The process is being executed.
- **Blocked (Waiting)**: The process is waiting for some event (such as I/O) to occur.
- **Terminated (Exit)**: The process has finished execution.

3. **Process Control Block (PCB)**: PCB is a data structure maintained by the operating system
for each process. It contains information about the process's state, including:

- **Process ID (PID)**: Unique identifier for the process.


- **Program Counter (PC)**: Address of the next instruction to be executed.
- **CPU Registers**: Current values of CPU registers.
- **Memory Management Information**: Base and limit registers, page tables, etc.
- **I/O Status Information**: List of I/O devices allocated to the process.
- **Process Scheduling Information**: Priority, scheduling state, etc.

4. **Role of Process Scheduler**: The process scheduler is responsible for selecting which
process should run next on the CPU. Its role includes:

- Maximizing CPU utilization.


- Fairly allocating CPU time among processes.
- Minimizing turnaround time and response time.
- Prioritizing processes based on scheduling policies.

5. **Degree of Multiprogramming**: It refers to the number of processes that are residing in


main memory at a given time.
- **I/O-bound Process**: Spends more time performing I/O operations than computations. It
frequently blocks to wait for I/O, making efficient use of CPU time.
- **CPU-bound Process**: Requires more CPU time and performs computations intensively. It
spends less time waiting for I/O and more time in the running state.

6. The term that describes saving the state of one process and restoring the state of another is
**context switching**. It involves saving the state of the currently executing process and loading
the saved state of another process to allow it to run.

7. Queueing-diagram representation of process scheduling:

![Queueing-diagram
representation](https://upload.wikimedia.org/wikipedia/commons/7/76/Queueing-diagram.png)

- **Different scheduling queues**:


- **Ready Queue**: Contains processes that are ready to run.
- **Waiting Queue**: Contains processes that are waiting for some event to occur (e.g., I/O
completion).
- **Suspended Queue**: Contains processes that are temporarily suspended, typically due to
resource limitations or scheduling policies.

8. **Types of CPU Schedulers**:


- **Long-term scheduler (job scheduler)**: Selects which processes should be brought into the
ready queue for execution. It controls the degree of multiprogramming.
- **Short-term scheduler (CPU scheduler)**: Selects which process should run next on the
CPU from the ready queue. It is invoked frequently and makes rapid decisions.

9. On UNIX systems, the system call that creates a process is `fork()`. When a process creates
a new process using `fork()`, the following state is shared between the parent process and the
child process:
- **c. Shared memory segments**

10. The system call that terminates a process on UNIX systems is `exit()`.
- **Zombie Process**: A process that has completed execution but still has an entry in the
process table.
- **Orphan Process**: A child process whose parent process has terminated or ended
unexpectedly.

11. **Independent process** operates separately and does not share data or resources with
other processes. **Cooperating process** can share data and resources, allowing them to
communicate and synchronize. Cooperation is necessary for tasks such as resource sharing,
communication, and distributed computing.

12. **Two fundamental models of interprocess communication**:


- **Shared Memory**: Processes share a portion of memory, allowing them to exchange data.
- **Message Passing**: Processes communicate by sending and receiving messages through
a communication link provided by the operating system.

13. The two bursts that CPU schedulers are designed around are:
- **CPU Burst**: The time a process spends executing on the CPU.
- **I/O Burst**: The time a process spends waiting for I/O operations to complete.

14. **Criteria for designing a CPU scheduling algorithm**:


- **CPU Utilization**: Maximizing CPU usage.
- **Throughput**: Number of processes completed per unit of time.
- **Turnaround Time**: Time taken to execute a process from submission to completion.
- **Waiting Time**: Total time a process spends waiting in the ready queue.
- **Response Time**: Time taken for the system to respond to a request.

15. **Preemptive scheduling** allows the operating system to interrupt a process and allocate
the CPU to another process. **Nonpreemptive scheduling** does not allow such interruptions; a
process keeps the CPU until it voluntarily relinquishes it.

16.
a. **Average turnaround time for FCFS scheduling**:
Average Turnaround Time = ((0 + 8) + (8 + 4) + (12 + 1)) / 3 = 33 / 3 = 11 time units.

b. **Average turnaround time for SJF scheduling**:


Average Turnaround Time = ((0 + 1) + (1 + 4) + (5 + 8)) / 3 = 19 / 3 ≈ 6.33 time units.

You might also like