int main () {
int i;
for (i = 0; i < 3; i++){
if (fork() == 0){
continue;
}
break;
}
printf("Hello!");
return 0;
}
The total number of times that the printf statement gets executed is ________. (answer in integer)
Solve 9+ Processes, Threads, System Calls and Context Switching previous year questions for GATE CS with answers and detailed solutions. Free sample questions
Answer it here to see how it works. Nothing is recorded until you sign in.
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.
Solve 9+ Processes, Threads, System Calls and Context Switching previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.
This chapter builds your understanding of how the operating system manages execution. Here is what you will master:
By the end of this chapter, you will be able to trace process state transitions, calculate context switch overhead, distinguish between process and thread behavior, predict the number of processes created by fork loops, and identify which operations trigger user-to-kernel mode transitions.
A process is a program in execution. It is the fundamental unit of work in a modern operating system.
| Aspect | Program | Process |
|---|---|---|
| Nature | Passive entity | Active entity |
| Storage | Stored on disk | Loaded in memory |
| Analogy | Recipe in a cookbook | The act of cooking |
| Lifetime | Permanent file | Temporary execution |
A process in memory contains:
The operating system tracks each process using a Process Control Block (PCB). Think of it as the process identity card. It contains:
The PCB is the key data structure that allows the operating system to support multiple processes simultaneously.
Consider a process P running on a CPU. Which one or more of the following events will always trigger a context switch by the OS that results in process P moving to a non-running state (e.g., ready, blocked)?
Which of the following statements about threads is/are TRUE?
Which of the following process state transitions is/are NOT possible?
Which one or more of the following options guarantee that a computer system will transition from user mode to kernel mode?
Which one or more of the following need to be saved on a context switch from one thread (T1) of a process to another thread (T2) of the same process?
Which of the following standard C library functions will <i>always</i> invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?