Operating Systems: Processes

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

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?

  • Text Section (correct)
  • Data Section
  • Stack
  • Heap

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?

<p>Some event to occur. (A)</p> Signup and view all the answers

What is the purpose of a 'process identifier' (pid)?

<p>To manage and identify a process. (D)</p> Signup and view all the answers

What happens in UNIX when a child process is created as an exact duplicate of the parent?

<p>Address space is exact duplicate of parent (code, data, program, etc.) (D)</p> Signup and view all the answers

In the context of process termination, what is a 'zombie' process?

<p>A process whose execution has finished, but the parent process has not yet collected its status. (D)</p> Signup and view all the answers

Which of the following is NOT typically stored in a Process Control Block (PCB)?

<p>List of past commands (B)</p> Signup and view all the answers

What is a key challenge in inter-process communication (IPC) using shared memory?

<p>Synchronizing the actions of user processes when they access the shared memory. (C)</p> Signup and view all the answers

What are the two fundamental operations provided by an Inter-Process Communication (IPC) facility for message passing?

<p>send(message) and receive(message) (D)</p> Signup and view all the answers

What is a key consideration when implementing message passing between processes?

<p>Determining whether the communication link should be unidirectional or bi-directional. (B)</p> Signup and view all the answers

In the context of the producer-consumer problem, what is a primary challenge?

<p>Preventing the producer from inserting data on a full buffer and the consumer from removing data from an empty buffer. (A)</p> Signup and view all the answers

What is another name for process switching?

<p>Context switch (D)</p> Signup and view all the answers

When a process switch occurs, what is the first step involved?

<p>Save the context of the processor (A)</p> Signup and view all the answers

What are threads?

<p>Multiple locations that can execute at once. (A)</p> Signup and view all the answers

Which of the following describes a multithreading process?

<p>Dividing a program/application into many small independent threads. (D)</p> Signup and view all the answers

Which one is true about threads vs process?

<p>A thread is a dispatch able unit of work . (D)</p> Signup and view all the answers

Which one is true about shared memory?

<p>The communication is under the control of the users processes not the operating system. (A)</p> Signup and view all the answers

If process P and Q wish to communicate, what must be done?

<p>Establish a communication link between them (D)</p> Signup and view all the answers

If a process is terminated without its parent invoking wait() what happens?

<p>orphan (B)</p> Signup and view all the answers

If no parent is waiting (did not invoke wait()), what happens to the process?

<p>zombie (C)</p> Signup and view all the answers

If a parent process terminates a child process what system call is used?

<p>abort() (B)</p> Signup and view all the answers

What system call does a process use to delete itself?

<p>exit() (B)</p> Signup and view all the answers

When the operating system chooses one of the processes in the ready state for running which process state transition occurs?

<p>Ready -&gt; Running (B)</p> Signup and view all the answers

What process state transition occurs when a new process is created?

<p>Null -&gt; New (C)</p> Signup and view all the answers

What are the three types of physical implementation of a communication link?

<p>Shared memory, Hardware bus, Network (A)</p> Signup and view all the answers

What has multiple locations that can execute at once?

<p>Threads (A)</p> Signup and view all the answers

What are two models of IPC?

<p>Shared memory, Message passing (C)</p> Signup and view all the answers

What is needed between processes P and Q to allow them to communicate?

<p>Communication Link (D)</p> Signup and view all the answers

Which statement is true regarding process?

<p>Process execution must progress in sequential fashion. (C)</p> Signup and view all the answers

Which one of the items below may affect or be affected by other processes?

<p>Cooperating process (C)</p> Signup and view all the answers

Which is a reason for cooperating processes?

<p>Computation Speedup (C)</p> Signup and view all the answers

In which process state are instructions being executed?

<p>Running (B)</p> Signup and view all the answers

In which process state is a process waiting to be assigned to a processor?

<p>Ready (A)</p> Signup and view all the answers

Signup and view all the answers

Signup and view all the answers

Flashcards

Process

A program in execution; process execution must progress in sequential fashion.

Text section

The program code of a process, also known as the text section.

Stack

Contains temporary data such as function parameters, return addresses, and local variables.

Data Section

The section of a process that contains global and static variables.

Signup and view all the flashcards

Heap

Contains memory dynamically allocated during run time.

Signup and view all the flashcards

Passive entity

An entity stored on disk

Signup and view all the flashcards

Active entity

An instance of a program in execution.

Signup and view all the flashcards

Foreground processes

Processes that interact with users and perform work for them.

Signup and view all the flashcards

Background processes

Processes not directly associated with users that run in the background and usually do not need user input.

Signup and view all the flashcards

New Process State

The process is being created.

Signup and view all the flashcards

Ready Process State

The process waiting to be assigned to a processor.

Signup and view all the flashcards

Running Process State

Instructions are being executed.

Signup and view all the flashcards

Waiting Process State

The process is waiting for some event to occur.

Signup and view all the flashcards

Terminated Process State

The process has finished execution.

Signup and view all the flashcards

Null to New

Occurs when a new process is created to execute a program.

Signup and view all the flashcards

New to Ready

Occurs when the operating system is prepared to take on an additional process and a new process is admitted.

Signup and view all the flashcards

Ready to Running

Occurs when the operating system chooses one of the processes in the ready state for running.

Signup and view all the flashcards

Running to Blocked

Occurs when a process requests something for which it must wait.

Signup and view all the flashcards

Blocked to Ready

Occurs when the event for which a process has been waiting occurs.

Signup and view all the flashcards

Running to Ready

Occurs when a process is preempted by the operating system.

Signup and view all the flashcards

Running to Exit

Occurs when a currently running process is terminated.

Signup and view all the flashcards

Blocked to Exit

When a parent process terminates a child process.

Signup and view all the flashcards

Parent process

Create children processes, which form a tree of processes.

Signup and view all the flashcards

Process identifier

process identified and managed via a process identifier

Signup and view all the flashcards

Address space

Memory that is available for a process.

Signup and view all the flashcards

fork()

A system call that creates new process.

Signup and view all the flashcards

exec()

A system call used after a fork() to replace the process' memory space with a new program.

Signup and view all the flashcards

exit()

Process executes last statement and then asks the operating system to delete it using the system call.

Signup and view all the flashcards

abort()

Parent may terminate the execution of children processes using the system call.

Signup and view all the flashcards

Zombie process

If no parent is waiting (did not invoke), process is a

Signup and view all the flashcards

Orphan process

If parent terminated without invoking wait, process is an

Signup and view all the flashcards

Process Control Block

information associated with each process.

Signup and view all the flashcards

Message passing

The process writes a message to the queue, and the other process reads the message from the queue.

Signup and view all the flashcards

Threads

Threads can shre resources.

Signup and view all the flashcards

Multi threading

It is the process of dividing a program into threads.

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.
  • 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.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser