1. What common events lead to the creation of a process?
Four common events lead to the creation of a process. There are:

1.   New batch job
2.   Interactive logon
3.   Created by operating system to provide a service
4.   Spanned by existing process.

2.Describe the actions taken by a kernel to switch context between processes.
Answer
    1. In response to a clock interrupt, the OS saves the PC and user stack pointer of the currently executing
        process, and transfers control to the kernel clock interrupt handler.
    2. The clock interrupt handler saves the rest of the registers, as well as other machine state, such as the
        state of the floating point registers, in the process PCB.
    3. The OS invokes the scheduler to determine the next process to execute,
    4. The OS then retrieves the state of the next process from its PCB, and restores the registers. This
        restore operation takes the processor back to the state in which this process was previously
        interrupted, executing in user code with user mode privileges.

3.What is a thread? How thread is different from a process and how and where they are used? What resources
are used when a thread is created?
a. A thread is a single sequential flow of control within a program.
b. A process creation additionally results in memory being allocated for program instructions (text) and data.
c. A context must be created, including a register set storage location for storage during context switching, and
a local stack to record the procedure call arguments, return values, and return addresses, and thread-local
storage.

4. Define the difference between preemptive and nonpreemptive scheduling. State why strict nonpreemptive
scheduling is unlikely to be used in a computer center.

Answer .
In nonpreemptive scheduling, a process remains in the running state until it explicitly performs an action that
will move it to either the ready or waiting scheduling queues (e.g., yield()). In preemptive scheduling, a
running process also moves to the ready or waiting scheduling queues by external acts occurring outside the
running process (e.g., a timer interrupt).

A computer center is mostly like a time-sharing system with multiple users and will probably not use
nonpreemptive scheduling because in nonpreemptive schedulers one process can conceivably consume all of
the available CPU cycles to the detriment of waiting jobs.

5. Consider a variant of the Round Robin (RR) scheduling algorithm where the entries inthe ready queue is
pointers to the Process Control Block's (PCB).
(a) What would be the effect of putting two pointers to the same process in the ready queue?
(b) What would be the major advantages and disadvantages of this scheme?
(c) How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?

Answer
(a) Process appear twice in the ready queue and is scheduled twice as often as other processes.
(b) Advantage: implement priorities. Disadvantage: overheads in maintaining pointers; same number of
context switches.
(c) Adaptive quantums for each process. A higher priority process can use up to 2/3/4/etc. quantums of time
over the single quantum for normal processes.

6.Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that
have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programs and
yet not permanently starve CPU-bound programs?

Answer
It will favor the I/O-bound programs because of the relatively short CPU burst requested by them (least
processor time); however, the CPU-bound programs will not starve because the I/O-bound programs will
relinquish the CPU relatively more often to do their I/O.

7. A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given n
processes to be scheduled on one processor, how many possible different schedules are there?

Operating system Q/A

  • 1.
    1. What commonevents lead to the creation of a process? Four common events lead to the creation of a process. There are: 1. New batch job 2. Interactive logon 3. Created by operating system to provide a service 4. Spanned by existing process. 2.Describe the actions taken by a kernel to switch context between processes. Answer 1. In response to a clock interrupt, the OS saves the PC and user stack pointer of the currently executing process, and transfers control to the kernel clock interrupt handler. 2. The clock interrupt handler saves the rest of the registers, as well as other machine state, such as the state of the floating point registers, in the process PCB. 3. The OS invokes the scheduler to determine the next process to execute, 4. The OS then retrieves the state of the next process from its PCB, and restores the registers. This restore operation takes the processor back to the state in which this process was previously interrupted, executing in user code with user mode privileges. 3.What is a thread? How thread is different from a process and how and where they are used? What resources are used when a thread is created? a. A thread is a single sequential flow of control within a program. b. A process creation additionally results in memory being allocated for program instructions (text) and data. c. A context must be created, including a register set storage location for storage during context switching, and a local stack to record the procedure call arguments, return values, and return addresses, and thread-local storage. 4. Define the difference between preemptive and nonpreemptive scheduling. State why strict nonpreemptive scheduling is unlikely to be used in a computer center. Answer . In nonpreemptive scheduling, a process remains in the running state until it explicitly performs an action that will move it to either the ready or waiting scheduling queues (e.g., yield()). In preemptive scheduling, a running process also moves to the ready or waiting scheduling queues by external acts occurring outside the running process (e.g., a timer interrupt). A computer center is mostly like a time-sharing system with multiple users and will probably not use nonpreemptive scheduling because in nonpreemptive schedulers one process can conceivably consume all of the available CPU cycles to the detriment of waiting jobs. 5. Consider a variant of the Round Robin (RR) scheduling algorithm where the entries inthe ready queue is pointers to the Process Control Block's (PCB). (a) What would be the effect of putting two pointers to the same process in the ready queue? (b) What would be the major advantages and disadvantages of this scheme? (c) How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers? Answer (a) Process appear twice in the ready queue and is scheduled twice as often as other processes. (b) Advantage: implement priorities. Disadvantage: overheads in maintaining pointers; same number of context switches. (c) Adaptive quantums for each process. A higher priority process can use up to 2/3/4/etc. quantums of time over the single quantum for normal processes. 6.Suppose that a scheduling algorithm (at the level of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O-bound programs and yet not permanently starve CPU-bound programs? Answer
  • 2.
    It will favorthe I/O-bound programs because of the relatively short CPU burst requested by them (least processor time); however, the CPU-bound programs will not starve because the I/O-bound programs will relinquish the CPU relatively more often to do their I/O. 7. A CPU scheduling algorithm determines an order for the execution of its scheduled processes. Given n processes to be scheduled on one processor, how many possible different schedules are there?