Podcast
Questions and Answers
In the context of operating systems, what distinguishes a 'process' from a 'program'?
In the context of operating systems, what distinguishes a 'process' from a 'program'?
- A process is a passive entity stored on disk, while a program is an active entity.
- A program is a passive entity stored on disk, while a process is an active entity. (correct)
- A program is a set of instructions, while a process is the hardware executing those instructions.
- A process is a single, sequential set of instructions; a program can execute concurrently.
A program has multiple parts, which part represents the current activity and contents of the processor's registers?
A program has multiple parts, which part represents the current activity and contents of the processor's registers?
- Text Section (correct)
- Data Section
- Stack
- Heap
How does a foreground process differ from a background process?
How does a foreground process differ from a background process?
- Background processes have higher priority and require user input.
- Foreground processes interact with users and are typically executed first with higher priority. (correct)
- Foreground processes are directly associated with users and run in the background.
- Background processes interact with users and run on the screen.
When a process is in the 'waiting' state, what is it typically waiting for?
When a process is in the 'waiting' state, what is it typically waiting for?
What is the purpose of a 'process identifier' (pid)?
What is the purpose of a 'process identifier' (pid)?
What happens in UNIX when a child process is created as an exact duplicate of the parent?
What happens in UNIX when a child process is created as an exact duplicate of the parent?
In the context of process termination, what is a 'zombie' process?
In the context of process termination, what is a 'zombie' process?
Which of the following is NOT typically stored in a Process Control Block (PCB)?
Which of the following is NOT typically stored in a Process Control Block (PCB)?
What is a key challenge in inter-process communication (IPC) using shared memory?
What is a key challenge in inter-process communication (IPC) using shared memory?
What are the two fundamental operations provided by an Inter-Process Communication (IPC) facility for message passing?
What are the two fundamental operations provided by an Inter-Process Communication (IPC) facility for message passing?
What is a key consideration when implementing message passing between processes?
What is a key consideration when implementing message passing between processes?
In the context of the producer-consumer problem, what is a primary challenge?
In the context of the producer-consumer problem, what is a primary challenge?
What is another name for process switching?
What is another name for process switching?
When a process switch occurs, what is the first step involved?
When a process switch occurs, what is the first step involved?
What are threads?
What are threads?
Which of the following describes a multithreading process?
Which of the following describes a multithreading process?
Which one is true about threads vs process?
Which one is true about threads vs process?
Which one is true about shared memory?
Which one is true about shared memory?
If process P and Q wish to communicate, what must be done?
If process P and Q wish to communicate, what must be done?
If a process is terminated without its parent invoking wait() what happens?
If a process is terminated without its parent invoking wait() what happens?
If no parent is waiting (did not invoke wait()), what happens to the process?
If no parent is waiting (did not invoke wait()), what happens to the process?
If a parent process terminates a child process what system call is used?
If a parent process terminates a child process what system call is used?
What system call does a process use to delete itself?
What system call does a process use to delete itself?
When the operating system chooses one of the processes in the ready state for running which process state transition occurs?
When the operating system chooses one of the processes in the ready state for running which process state transition occurs?
What process state transition occurs when a new process is created?
What process state transition occurs when a new process is created?
What are the three types of physical implementation of a communication link?
What are the three types of physical implementation of a communication link?
What has multiple locations that can execute at once?
What has multiple locations that can execute at once?
What are two models of IPC?
What are two models of IPC?
What is needed between processes P and Q to allow them to communicate?
What is needed between processes P and Q to allow them to communicate?
Which statement is true regarding process?
Which statement is true regarding process?
Which one of the items below may affect or be affected by other processes?
Which one of the items below may affect or be affected by other processes?
Which is a reason for cooperating processes?
Which is a reason for cooperating processes?
In which process state are instructions being executed?
In which process state are instructions being executed?
In which process state is a process waiting to be assigned to a processor?
In which process state is a process waiting to be assigned to a processor?
Flashcards
Process
Process
A program in execution; process execution must progress in sequential fashion.
Text section
Text section
The program code of a process, also known as the text section.
Stack
Stack
Contains temporary data such as function parameters, return addresses, and local variables.
Data Section
Data Section
Signup and view all the flashcards
Heap
Heap
Signup and view all the flashcards
Passive entity
Passive entity
Signup and view all the flashcards
Active entity
Active entity
Signup and view all the flashcards
Foreground processes
Foreground processes
Signup and view all the flashcards
Background processes
Background processes
Signup and view all the flashcards
New Process State
New Process State
Signup and view all the flashcards
Ready Process State
Ready Process State
Signup and view all the flashcards
Running Process State
Running Process State
Signup and view all the flashcards
Waiting Process State
Waiting Process State
Signup and view all the flashcards
Terminated Process State
Terminated Process State
Signup and view all the flashcards
Null to New
Null to New
Signup and view all the flashcards
New to Ready
New to Ready
Signup and view all the flashcards
Ready to Running
Ready to Running
Signup and view all the flashcards
Running to Blocked
Running to Blocked
Signup and view all the flashcards
Blocked to Ready
Blocked to Ready
Signup and view all the flashcards
Running to Ready
Running to Ready
Signup and view all the flashcards
Running to Exit
Running to Exit
Signup and view all the flashcards
Blocked to Exit
Blocked to Exit
Signup and view all the flashcards
Parent process
Parent process
Signup and view all the flashcards
Process identifier
Process identifier
Signup and view all the flashcards
Address space
Address space
Signup and view all the flashcards
fork()
fork()
Signup and view all the flashcards
exec()
exec()
Signup and view all the flashcards
exit()
exit()
Signup and view all the flashcards
abort()
abort()
Signup and view all the flashcards
Zombie process
Zombie process
Signup and view all the flashcards
Orphan process
Orphan process
Signup and view all the flashcards
Process Control Block
Process Control Block
Signup and view all the flashcards
Message passing
Message passing
Signup and view all the flashcards
Threads
Threads
Signup and view all the flashcards
Multi threading
Multi threading
Signup and view all the flashcards
Study Notes
- Programs on an operating system can be broken down into jobs for batch systems or user programs/tasks for time-shared systems.
- The terms "job" and "process" are often used interchangeably in textbooks.
- A process is a program in execution that progresses sequentially.
Process Components
-
Text Section: Program Code.
-
Current Activity: Values of the Program Counter and processor's registers.
-
Stack: Temporary data, including function parameters, return addresses, and local variables.
-
Data Section: Global and static variables.
-
Heap: Memory dynamically allocated during runtime.
-
A program is a passive entity stored on disk as an executable file, while a process is an active entity.
-
Programs become processes once loaded into memory.
-
Program execution can start from GUI clicks or command lines.
-
One program can result in multiple processes, such as multiple users running the same program.
-
A process requires resources like CPU, memory, I/O, files, and initialization data, allocated on creation or during execution.
Types of Processes
- Foreground Processes: Interact w/ users, they run on-screen, need user input & they have higher priority; e.g., Office Programs, browsers.
- Background Processes (Daemons): Not directly user-associated, run in the background, require less user input; e.g., spell-checker, printer program.
Process State
- The state of a process changes as it executes.
- New: The process is being created.
- Ready: Process waiting for processor assignment; kept in a ready queue.
- Running: Instructions are being executed.
- Waiting: The process is waiting for an event, placed in a waiting queue.
- Terminated: The process has finished its execution.
- An operating system performs all of the previous tasks.
State Transitions
- Null to New: Occurs when a process is created to execute a program.
- New to Ready: Occurs when the operating system admits a new process.
- Ready to Running: The operating system chooses a process in the ready state to run; dispatching happens here, managed by the dispatcher (scheduler).
- Running to Blocked: Occurs when a process requests something for which it must wait (e.g., I/O operation, file, input/message from another process, shared virtual memory).
- Blocked to Ready: Occurs when the event a process was waiting for happens.
- Running to Ready: Occurs when a process is preempted by the operating system (e.g., time expired, higher priority process moves to ready state, timeout).
- Running to Exit: Occurs when a running process terminates.
- Ready to Exit.
- Blocked to Exit.
Operations
-
Process Creation: OS, parent process or user create a process.
-
Process Termination: OS, parent process or user terminates a process.
-
Resource Allocation: Allocate and de-allocate resources.
-
A parent process creates child processes, forming a process tree.
-
Processes are identified and managed using a process identifier (pid).
Resource Sharing
- Parent and children sharing all resources.
- Children sharing a subset of parent's resources.
- Parent and child sharing no resources.
Execution options
- Parent and children execute concurrently.
- Parent waits until children terminate.
- Address space is the memory available for a process.
- Child Duplicate of a parent has the same address space (code, data, program).
- Child loading a program into it creates a separate address space for the child.
- fork() is a system call, in UNIX, that creates a new process.
- exec() is a system call used after fork() to replace the process's memory space.
Process Termination
- The exit() system call is used by a process to request its deletion from the OS after its final statement.
- Parent receives the status data from the child via wait().
- Operating system then de-allocates resources
- The abort() system call is used by parents to terminate the execution of child processes.
- Termination Reasons: Child exceeding allocated resources, task no longer required, or parent exiting.
- The wait() system call is uased by a parent process to wait for a child's termination, it returns termination status and the pid of the exited process.
- Zombie processes result from a parent not waiting (not invoking wait()) for a child.
- Orphan processes result from a parent terminating without invoking wait.
Termination can occur through:
- Normal, voluntary exit.
- Voluntary error exit.
- Involuntary fatal error.
- Being killed by another process involuntarily.
Process Control Block (PCB)
- The PCB, stores information for each process.
- Components: process state, program counter (next instruction location), CPU registers, CPU scheduling info, memory management info, accounting info, & I/O status.
Interprocess Communication (IPC)
- Independent processes cannot affect other processes.
- Cooperating processes can affect or be affected by each other, including sharing data.
- Cooperation Reasons: information sharing, computation speedup, modularity.
- Google Chrome's new tab feature uses a separate thread.
- IPC is necessary for cooperating processes.
IPC Models
- Shared Memory: Processes access a common memory area.
- Message Passing: Processes communicate through exchanging messages.
- Other methods: using pipes, sockets, etc.
Shared Memory
- Shared memory communications are under user process control, not the OS.
- It's Important to synchronize for user processes to ensure actions access shared memory properly.
Message Passing
- Processes communicate and synchronize actions through messages.
- The sender writes to a queue/buffer, the receiver reads from it.
- Systems don't need shared variables.
- send(message) is one of two operations, for communication, under IPC.
- receive(message) is the second.
- Messages can be fixed or variable in size.
- Processes "P" and "Q" need to establish a communication link and exchange messages via send/receive to communicate.
Communication Link Implementation Issues:
- Establishment
- Link association
- Link quantity
- Link capacity
- Message size accommodation
- Unidirectional or bi-directional link
Implementation
- Physical: shared memory (single-processor), hardware bus (multi-processor), or network (distributed systems).
- Logical: Direct or indirect, synchronous or asynchronous, and automatic or explicit buffering.
Producer-Consumer Paradigm
- A producer process generates information to a consumer process.
- The producer inserts data in an empty buffer slot.
- A consumer removes data from a filled slot.
- The consumer removes data from filled slots.
- Errors arise when a producer adds to a full buffer.
- Errors arise when a consumer removes data from an empty buffer.
- Concurrent insertion and removing lead to errors.
Process Switching
- Process switch, like context switch, occurs when the OS interrupts a running process to assigns another to a running state.
- Process Switch Involves: saving current context, PCB updates, queue adjustments, & memory management updates, and lastly, restoring.
Threads
- Thread is a manageable agent for task execution, sharing resources.
- Processes use a single thread of execution.
- Consider multiple program counters (multiple locations to execute)
- Create threads via multiple threads of control.
- Then you must have storage for thread details & multiple program counters in PCB.
- A program or application is divided into many independent threads through Multithreading.
- Examples; Excel application, client browser, multithread server, OS, implemented using multithreads.
- Each thread owns program counter (tracks instructions), stack, registers (hold current variables and history of execution).
Thread vs. Process
- A process is a collection of threads sharing resources.
- A thread is a dispatchable work unit.
- Traditional OS are single-threaded.
- Modern OS are, multithreaded.
- Processes have heavy weighting and interact with the OS.
- Threads have light weighting and do not interact OS.
- Processes are independent, but threads aren't.
- Independent data and code segments are used for processes while they share them among them for threads.
- Processes consume more resources, while threads, consume less.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.