Processes and Threads

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

What is the primary responsibility of an operating system concerning processes?

  • Designing new applications.
  • Memory allocation only.
  • Ensuring all background processes run at the same priority.
  • Controlling process execution, including interleaving and resource allocation. (correct)

How does the OS determine the order in which processes should be executed?

  • By randomly assigning execution time.
  • By considering interleaving pattern and allocating resources. (correct)
  • By assigning processes to users.
  • By using virtual memory allocation.

What happens to a process when it is interrupted?

  • It is immediately terminated.
  • It is given new resources.
  • It proceeds to execute.
  • It is transferred to the queue of waiting process. (correct)

What is the initial state of a process when the OS creates it?

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

What is required for the OS to manage processes effectively?

<p>Information about the current status of each process and resource. (B)</p> Signup and view all the answers

What is the purpose of an identifier in the context of processes?

<p>Distinguishing amongst all other processes (A)</p> Signup and view all the answers

Which of the following is included in I/O status information?

<p>I/O devices assigned to the process. (C)</p> Signup and view all the answers

In what state do processes exist, known to the OS, waiting to execute?

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

What is a 'trace' of a process?

<p>A listing of the sequence of instructions that execute for that process. (B)</p> Signup and view all the answers

What is the role of the dispatcher?

<p>To select the next process to run. (A)</p> Signup and view all the answers

What is process spawning?

<p>When the OS creates a process at the explicit request of another process. (C)</p> Signup and view all the answers

In a five-state process model, if a process is waiting for an I/O operation to complete, what state would it be in?

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

The physical processor is switched among multiple applications so all will appear to be progressing. What concept does this describe?

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

Why is the New state useful in process management?

<p>It allows the OS to postpone committing to the execution of a process. (B)</p> Signup and view all the answers

What is the difference between the Ready and Ready/Suspend states?

<p>A Ready process is in main memory, while a Ready/Suspend process is in secondary memory. (B)</p> Signup and view all the answers

Why does the OS prefer to suspend a blocked process rather than a ready process?

<p>the ready process can now be executed. (D)</p> Signup and view all the answers

Consider all this information, what describes a process control block?

<p>Priority of the process to other processes. (D)</p> Signup and view all the answers

What is the key distinction between kernel mode and user mode?

<p>Kernel mode has complete control of the processor and its instructions. (B)</p> Signup and view all the answers

What would describe the circumstances where an operating system routine is executed?

<p>When an interrupt triggers execution or user makes a call. (A)</p> Signup and view all the answers

Which action is not part of the steps involved in creating a process?

<p>Check the processes location. (D)</p> Signup and view all the answers

Which action should the interrupt handler perform?

<p>Reset the flag that signals the presence of an interrupt. (C)</p> Signup and view all the answers

Why is memory management a critical aspect of Operating System control?

<p>It includes data structures to represent the state of each process. (B)</p> Signup and view all the answers

How does the processor determine what to do after an error that is found with a trap?

<p>Checks if a process is fatal. (D)</p> Signup and view all the answers

What tables might be needed to control a process?

<p>These tables must be linked alluding that all parts of the OS are linked. (C)</p> Signup and view all the answers

Which of the following is NOT a typical reason for process termination?

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

What is the relationship of a parent process and child process, with process spawning?

<p>The parent process creates the child process. (A)</p> Signup and view all the answers

The set of all processes that make up the current operating system describes which...

<p>Process Control Block (D)</p> Signup and view all the answers

Which of the following is NOT provided by memory tables?

<p>Whether any processes are performing I/O. (A)</p> Signup and view all the answers

When viewing source code, what would identify a memory page that is part of the kernel?

<p>Having identifiers. (C)</p> Signup and view all the answers

What is the key purpose of including suspension in a state diagram?

<p>There is a process that is not in main memory. (A)</p> Signup and view all the answers

When the operating system creates tables on initialization, what determines the structure of the table?

<p>Access to some configuration data. (D)</p> Signup and view all the answers

When a process spawns another process with process spawning, how do you identify a parent process versus a child process?

<p>The parent process is the process that spawned the new process, called the child. (C)</p> Signup and view all the answers

When is the process in a Ready State?

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

In a two state process model, what happens when a running state has been interrupted?

<p>OS selects another process to run. (B)</p> Signup and view all the answers

What is a parent termination?

<p>OS terminantes all of the offspring even if parent terminates (C)</p> Signup and view all the answers

After a process terminates, why might it be preserved by the OS?

<p>The job has completed but the OS still has data that needs to be collected. (C)</p> Signup and view all the answers

Flashcards

Operating System (OS)

A layer of software between applications and computer hardware. It provides a feature-rich, secure and consistent interface.

Process

An instance of a program running that can be assigned to and executed on a processor.

Essential Elements of a Process

Program code that may be shared and a set of data associated with that code

Process Control Block (PCB)

A data structure containing sufficient information to interrupt and resume a process.

Signup and view all the flashcards

Process Identifier

A unique identifier distinguishing a process from all others.

Signup and view all the flashcards

Process Priority

Priority level relative to other processes.

Signup and view all the flashcards

Program Counter

Address of the next instruction to be executed.

Signup and view all the flashcards

Context Data

Data present in registers while the process is running.

Signup and view all the flashcards

Trace of a Process

Sequence of instructions that execute for a specific process.

Signup and view all the flashcards

Two-State Process Model

The process is either being executed by a processor or not.

Signup and view all the flashcards

Ready State

Process is prepared to execute when given the opportunity

Signup and view all the flashcards

Blocked/Waiting State

Process cannot execute until an event occurs.

Signup and view all the flashcards

New State

Process has been created but not admitted into the executable pool.

Signup and view all the flashcards

Exit State

Process released from executable pool due to halting or abortion.

Signup and view all the flashcards

Suspend State

OS puts a process state when all processes are blocked.

Signup and view all the flashcards

Blocked/Suspend

The process is in secondary memory and awaiting an event.

Signup and view all the flashcards

Ready/Suspend

Process is in secondary memory but is available for execution.

Signup and view all the flashcards

Process Swapping

The OS releases main memory to bring in a process that is ready to execute.

Signup and view all the flashcards

Memory Tables

Keep track of both main and virtual memory allocation.

Signup and view all the flashcards

I/O Tables

Manage the I/O devices and channels of the computer system

Signup and view all the flashcards

Process Control Block

Data needed by the OS to control a process.

Signup and view all the flashcards

User Mode

Less privileged processor mode for user programs.

Signup and view all the flashcards

Kernel Mode

More privileged processor mode for the OS.

Signup and view all the flashcards

Process Switching

The OS assigns another process to Running and turns control to it.

Signup and view all the flashcards

Trap

A software generated interrupt.

Signup and view all the flashcards

Interrupt stage

Indicates that an interrupt signal is pending.

Signup and view all the flashcards

Nonprocess Kernel

OS executes the kernel outside of any process.

Signup and view all the flashcards

Execution within User Processes

OS executes withing the context of an existing user process.

Signup and view all the flashcards

Preempted (UNIX)

Process is returning from kernel to user, but the kernel preempts it.

Signup and view all the flashcards

UNIX Process 0

Data structure loaded at boot time; operates in kernel mode

Signup and view all the flashcards

UNIX Process 1 init

Created by swapper process 0 and all other processes are descended from it.

Signup and view all the flashcards

User-level context

Includes the user's program and data and can be generated directly from a compiled object file.

Signup and view all the flashcards

Register context

hardware context of the process image.

Signup and view all the flashcards

System-level context

The information the Operating System needs to run the process.

Signup and view all the flashcards

Study Notes

  • This chapter examines advanced concepts related to process management
  • The original concept of a process has two components: resources and execution
  • Operating systems are developing a construct known as a thread to address the two components

Processes and Threads

  • A process is a unit of resource allocation as well as a unit of protection
  • A process has a virtual address space for the process image
  • Processes are protected to prevent interference with resources, which can include; processors, other processes (for interprocess communication), files, and I/O resources
  • The execution of a process follows an execution path
  • A process has an execution state; Running, Ready etc
  • A process also has a dispatching priority that the OS can schedule if needed
  • A thread is the unit of dispatching
  • The unit of resource ownership is a process or task

Multithreading

  • An operating system’s ability to support multiple, concurrent paths of execution within a single process
  • A single thread of execution per process is a single-threaded approach
  • A Java run-time environment uses one process with multiple threads
  • Windows and Solaris use multiple processes that support multiple threads

Multithreaded Environment

  • Processes are the unit of resource allocation and a unit of protection

  • Processes have a virtual address space that holds the process image

  • Processes have access to processors, other processes (for interprocess communication), files, I/O resources

  • Threads exist within a process

  • Threads have an execution state (Running, Ready, etc.)

  • When threads are not running, their context is saved

  • Threads have an execution stack

  • Some per-thread static storage for local variables

  • Threads have access to the memory and resources of its process, which is shared with all other threads in that process

  • It takes less time to create/terminate a thread than a process

  • It takes less time to switch between two threads within a process than to switch between processes

  • Threads enhance efficiency in communication between different executing programs

  • The kernel intervenes to provide protection and mechanisms for communication between independent processes

  • Threads within the same process share memory and files, therefore they can communicate without the kernel

Thread States and Operations

  • Key states for a thread are Running, Ready, and Blocked

  • There are no Suspend states with threads

  • Basic thread operations that cause a change in state consist of the following,

  • Spawn: New process spawns a thread for that process

  • Block: Thread waits for event

  • Unblock: Event for which a thread is blocked occurs

  • Finish: Thread completes; register context and stacks are deallocated

Remote Procedure Call (RPC)

  • Remote procedure calls (RPCs) to two different hosts is used to get a combined result
  • Without threads, results are obtained in sequence; program waits for response from each server
  • With threads, requests processed with substantial speedup

Thread Synchronization

  • Threads of a process share the same address space and other resources like open files
  • Any alteration of a resource by one thread affects the environment of the other threads in the same process
  • The activities of the various threads synchronize so they don't interfere with each other or corrupt data structures

Types of Threads: User-Level Threads

  • The two categories of thread implementation include: User-level threads (ULTs) and kernel-level threads (KLTs)
  • All of the work of thread management is done by the application using a ULT
  • The kernel isn't aware of the existence of threads

ULT Advantages

  • Thread switching doesn’t require kernel mode privileges
  • Scheduling can be application-specific
  • ULTs can run on any OS

ULT Disadvantages

  • Many system calls are blocking, which blocks the entire process
  • Multithreaded applications cannot take advantage of multiprocessing
  • A kernel assigns one process to only one processor at a time

Kernel-Level Threads (KLTs)

  • All of the work of thread management is done by the kernel; uses an application programming interface (API) to the kernel thread facility

KLT Advantages

  • Kernel can schedule multiple threads from the same process on multiple processors
  • If one thread in a process is blocked, the kernel can schedule another thread of the same process
  • Kernel routines are multithreaded too

KLT Disadvantage

  • Requires a mode switch to the kernel to transfer control from one thread to another within the same process, which can be slow

Combined ULT/KLT Approaches

  • Provide a combined ULT/KLT facility
  • Thread creation completed in user space as well as scheduling and synchronization of threads
  • The application maps multiple ULTs onto some number of KLTs
  • The programmer adjusts the number of KLTs for a particular application to achieve the best overall results
  • Multiple threads can run in parallel on multiple processors
  • A system call need not block the entire process
  • Minimizes the disadvantages of all approaches

Relationships Between Threads and Processes

  • Traditional OS had 1:1 relationship between thread and process
  • Other systems include:
  • M:1: Processes an address space and dynamic resource ownership, multiple threads may be created and executed there
  • 1:M: The thread may migrate from one process environment to another, allowing the thread to be easily moved to distinct systems
  • M:N: Combines attributes of M:1 and 1:M cases

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