CS400 Operating Systems
Homework #3
Due (02/17/2017).
Turn in your HW on Scantron answer sheet to your grader in the beginning of the class
1. A process control block ____.
a) includes information on the process's state
b) stores the address of the next instruction to be processed by a different process
c) determines which process is to be executed next
d) is an example of a process queue
2. The number of processes completed per unit time is known as __________.
a) Output
b) Throughput
c) Efficiency
d) Capacity
3. Which of the following are contained in a Process Control Block (PCB)?
a) Code
b) The value of the CPU registers
c) Stack
d) Heap
e) All of the above
4. A _________________ saves the state of the currently running process and restores
the state of the next process to run.
a) save-and-restore
b) state switch
c) context switch
d) none of the above
5. The entry of all the PCBs of the current processes is in __________.
a) Process Register
b) Program Counter
c) Process Table
d) Process Unit
6. The degree of multi-programming is defined as _________.
a) the number of processes executed per unit time
b) the number of processes in the ready queue
c) the number of processes in the I/O queue
1
d) the number of processes in memory
7. The objective of multi-programming is to _________ and _________.(choose two)
a) Have some process running at all times
b) Have multiple programs waiting in a queue ready to run
c) To minimize CPU utilization
d) To maximize CPU utilization
8. Which of the following is a correct description of the long-Term Scheduling?
a) Swapping in/out processes to optimize Multiprogramming.
b) Decision on which programs are admitted to the system, controlling the degree of
Multiprogramming (number of processes in memory) to provide satisfactory
service to current set of processes.
c) As a Dispatcher, it makes decision on which process to execute next.
d) Block or preempt current process due to Clock Interrupts, I/O Interrupts, System
Calls, Signals (semphores).
e) Decision as to which process pending I/O request shall be handled by available
I/O Devices.
9. If all processes I/O bound, the ready queue will almost always be ______, and the
Short term Scheduler will have a ______ to do.
a) full,little
b) full,lot
c) empty,little
d) empty,lot
10. What is a medium-term scheduler?
a) It selects which process has to be brought into the ready queue
b) It selects which process has to be executed next and allocates CPU
c) It selects which process to remove from memory by swapping
d) None of these
11. What is a short-term scheduler?
a) It selects which process has to be brought into the ready queue
b) It selects which process has to be executed next and allocates CPU
c) It selects which process to remove from memory by swapping
d) None of these
12. The primary distinction between the short-term scheduler and the long-term scheduler
is ____________.
a) The length of their queues
b) The type of processes they schedule
c) The frequency of their execution
d) None of these
2
13. The only state transition that is initiated by the user process itself is ________.
a) block
b) wakeup
c) dispatch
d) None of these
14. In a time-sharing operating system, when the time slot given to a process is
completed, the process goes from the running state to the __________.
a) Blocked state
b) Ready state
c) Suspended state
d) Terminated state
15. Suppose that a process is in "Blocked" state waiting for some I/O service.
When the service is completed, it goes to the ___________.
a) Running state
b) Ready state
c) Suspended state
d) Terminated state
16. Which of the following state transitions is not possible?
a) blocked to running
b) ready to running
c) blocked to ready
d) running to blocked
17. State transition from Running to Ready: Which is not true?
a) Process has reached its quantum and OS uses scheduling algorithm to find next
process in the Ready state.
b) OS will preempt running Process, when a higher priority process is ready to run.
c) Process can also voluntarily release processor.
d) Process issues a request and must wait for the event.
18. When memory is sufficient, which processes will be swapped in first?
a) Ready/Suspend
b) Blocked/Suspend
c) Ready
d) Blocked
19. When memory is not enough, which processes will be swapped out first?
a) Ready
b) Ready/Suspend
c) Blocked
d) Blocked/Suspend
3
int value = 10; // global variable
int main() {
pid_t pid;
pid = fork();
if (pid == 0) { /* child process */
value += 10;
printf("Child: value = %d\n",value); /* LINE B */
return 0;
}else if (pid > 0) { /* parent process */
wait(NULL);
printf("Parent: value = %d\n",value); /* LINE A */
return 0;
}
}
What output will be at Line A?
a) Parent: value = 0
b) Parent: value = 10
c) Parent: value = 20
d) Parent: value = 30
20. What output will be at Line B?
a) Child: value = 0
b) Child: value = 10
c) Child: value = 20
d) Child: value = 30
21. Line B is definitely printed before Line A?
a) True
b) False
22. When a process is created using classical fork( ) system call, process ID is inherited
by the child process.
a) True
b) False
23. How many processes will be created in the following program?
#include <stdio.h>
#include <unistd.h>
int main()
{
int i;
for (i = 0; i < 6; i++) fork();
return 0;
}
a) 64
b) 32
4
c) 16
d) 5
e) 6
24. In the following program, the number of messages with "BBB" = ?
a) 2
b) 4
d) 8
d) 16
int main() {
pid_t pid = fork(); /* 1. fork a child process */
printf ("AAA, pid=%d.\n", pid); // print out AAA
pid = fork();
/* 2. fork another child process */
printf ("BBB, pid=%d.\n", pid); // print out BBB
pid = fork();
/* 3. and fork another */
printf ("CCC, pid=%d.\n", pid); // print out CCC
return 0;
}
25. (continue) In the above program, the number of messages with "BBB, pid=0" ?
a) 2
b) 4
c) 8
d) 16
26. In the following program, which of the following message will not be printed out?
a) LINE I.
b) LINE J.
c) LINE K.
int main() {
pid_t pid = fork();
if (pid < 0) { /* error occurred */
fprintf(stderr, "Fork Failed");
return 1;
}else if (pid == 0) { /* child process */
printf("LINE I.\n");
// LINE I: will this message be printed out?
execlp("/bin/ls","",NULL);
printf("LINE J.\n");
// will this message be printed out?
}else { /* parent process */
wait(NULL);
printf("LINE K.\n");
// will this message be printed out?
}
return 0;
}
27. Each process is represented in the Operating System by a Process Control Block
(PCB) data structure. What information is NOT kept in a process’s PCB?
a) Process State (New/Ready/Running/Waiting/Terminated).
b) Program Counter.
5
c) Mapping between the Process Pages to physical memory frame.
d) CPU Context (General Purpose Registers, Stack Pointers).
28. Which of the following components of program state are shared across threads in a
multithreaded process?
a) Register values
b) Global variables
c) Stack memory
29. Which of the following is true?
a) All processes in UNIX first translate to a zombie process upon termination.
b) The difference between a program and a process is that a program is an active
entity while a process is a passive entity.
c) The exec() system call creates a new process.
30. Which of the following is false?
a) Local Procedure Calls in Windows XP are similar to Remote Procedure Calls.
b) For a single-processor system, there will never be more than one process in the
Running state.
c) Shared memory is a more appropriate IPC mechanism than message passing for
distributed systems.
d) Ordinary pipes in UNIX (and Windows) require a parent-child relationship
between the communicating processes.
31. Linux and UNIX assign the “init” process as the new parent of orphan processes and
process “init” periodically calls wait() which allows any resources allocated to
terminated processes to be reclaimed by the operating system.
a) True
b) False
6
© Copyright 2025 Paperzz