Operating Systems: Process Concepts

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

Which of the following best describes a 'process' in the context of operating systems?

  • A program in execution, with its associated resources. (correct)
  • A passive entity stored on disk, such as an executable file.
  • A section of code containing global variables.
  • A program that is currently loaded into memory.

In which order must a process execute its instructions?

  • Random fashion
  • Parallel fashion
  • Sequential fashion (correct)
  • Concurrent fashion

Which of the following sections in a process's memory contains temporary data storage when invoking functions?

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

Which section of memory contains memory dynamically allocated during runtime?

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

Which of the following states is NOT a typical process state?

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

When the OS changes the CPU core from one process to another, requiring saving the state of the current process and loading the state of the new process, what is this operation called?

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

Why is context switch time considered overhead?

<p>It's unproductive, as the system performs no useful work during switching. (A)</p> Signup and view all the answers

What is a process identifier (PID) used for?

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

What is the term for the situation when a parent process terminates and its children must also be terminated?

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

What are the two fundamental models of Interprocess Communication (IPC)?

<p>Shared Memory and Message Passing (B)</p> Signup and view all the answers

What is required for processes to communicate using message passing?

<p>A communication link. (C)</p> Signup and view all the answers

Which of the following is a characteristic of direct communication in message passing?

<p>Processes must explicitly name each other. (D)</p> Signup and view all the answers

What is the purpose of 'stubs' in the context of Remote Procedure Calls (RPC)?

<p>To serve as client-side proxies for the actual procedure on the server. (D)</p> Signup and view all the answers

In process management, what does the 'ready queue' primarily contain?

<p>Processes residing in memory, ready and waiting to execute. (B)</p> Signup and view all the answers

In the context of process states, what is typically indicated when a process is in the 'waiting' state?

<p>The process is waiting for an event to occur. (D)</p> Signup and view all the answers

What information is NOT typically stored in a Process Control Block (PCB)?

<p>Process creation timestamp (B)</p> Signup and view all the answers

A program is best described as which of the following?

<p>A passive entity. (D)</p> Signup and view all the answers

Which of the following best describes the relationship between a program and a process?

<p>A process is an instance of a program. (A)</p> Signup and view all the answers

In the memory layout of a C program, what is the primary purpose of the 'data' section?

<p>To store global variables. (B)</p> Signup and view all the answers

In UNIX-like systems, which system call is used to create a new process?

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

If a parent process wants to wait for its child process to complete execution, which system call can it use?

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

In the context of process termination, which action is typically performed by the operating system?

<p>Deallocating process resources. (D)</p> Signup and view all the answers

What is the primary difference between cooperating and independent processes?

<p>Cooperating processes can affect or be affected by other processes. (B)</p> Signup and view all the answers

Which of the following scenarios benefits most from interprocess communication (IPC)?

<p>Sharing data between multiple processes. (B)</p> Signup and view all the answers

In the producer-consumer problem, what is a characteristic of an 'unbounded-buffer'?

<p>There is no practical limit on the size of the buffer. (D)</p> Signup and view all the answers

Which interprocess communication (IPC) method involves a region of memory that is shared among processes?

<p>Shared Memory (D)</p> Signup and view all the answers

What is the primary role of the 'send' and 'receive' operations in message passing?

<p>To transfer data between processes. (A)</p> Signup and view all the answers

What does 'synchronous' communication typically imply in the context of message passing?

<p>The sender and receiver are blocked until the message transfer is complete. (A)</p> Signup and view all the answers

What is the purpose of buffering in interprocess communication?

<p>To queue messages attached to the communication link. (A)</p> Signup and view all the answers

In the realm of inter-process communication, which characteristic describes 'ordinary pipes'?

<p>Communication only between processes that share a parent-child relationship. (B)</p> Signup and view all the answers

In contrast to ordinary pipes, what advantage do 'named pipes' offer in inter-process communication?

<p>They can be accessed without a parent-child relationship. (C)</p> Signup and view all the answers

What is a 'well known' port in the context of socket communication?

<p>A port number used for standard services. (C)</p> Signup and view all the answers

In the context of inter-process communication, what is the loopback address (127.0.0.1) primarily used for?

<p>Referencing the system on which a process is running. (C)</p> Signup and view all the answers

What is the role of the marshalling process within Remote Procedure Calls (RPC)?

<p>Packaging parameters for network transfer. (C)</p> Signup and view all the answers

In the context of buffering, what happens when there is 'zero capacity'?

<p>The sender waits for the receiver (C)</p> Signup and view all the answers

A named pipe...

<p>is more powerful than an ordinary pipe because communication is bi-directional (A)</p> Signup and view all the answers

Flashcards

What is a Process?

A program in execution, progressing in a sequential manner.

What represents process's current activity?

The state represented by the program counter and processor's registers.

What is a Program?

A passive entity stored on disk.

What is a Process?

An active entity loaded into memory.

Signup and view all the flashcards

What is a Text Section?

The 'code' part of a process in memory, also known as the executable.

Signup and view all the flashcards

What is Data section?

Memory section containing global variables.

Signup and view all the flashcards

What is Heap?

Memory dynamically allocated during runtime.

Signup and view all the flashcards

What is Stack in memory?

Temporary data storage when invoking functions parameter, return addresses, and local variables.

Signup and view all the flashcards

What is the 'New' process state?

The process is being created.

Signup and view all the flashcards

What is the 'Running' process state?

Instructions are being executed.

Signup and view all the flashcards

What is the 'Waiting' process state?

The process is waiting for some event to occur.

Signup and view all the flashcards

What is the 'Ready' process state?

The process is waiting to be assigned to a processor.

Signup and view all the flashcards

What is the 'Terminated' process state?

The process has finished execution.

Signup and view all the flashcards

What is Process Control Block(PCB)?

Data structure representing a process in the OS.

Signup and view all the flashcards

What is a Program Counter in PCB?

Address of the next instruction in the PCB for the process.

Signup and view all the flashcards

What are CPU Registers in PCB?

Stores accumulators, index registers, stack pointers, etc. in PCB.

Signup and view all the flashcards

What is a Ready Queue?

The linked list containing PCBs of ready processes.

Signup and view all the flashcards

What is a Wait Queue?

The linked list of processes that are waiting.

Signup and view all the flashcards

What is a Context Switch?

The act of switching the CPU from one process to another.

Signup and view all the flashcards

What happens in Context Switch?

Saving the state of current process and restoring state of new.

Signup and view all the flashcards

How are processes created?

A process creates child processes, forming a tree.

Signup and view all the flashcards

What is a PID?

Unique value used to identify and manage a process.

Signup and view all the flashcards

What is a fork()?

System call creates a new process.

Signup and view all the flashcards

What is an exec()?

System call replaces the process' memory with a new program.

Signup and view all the flashcards

What is wait()?

System call where parent process waits of termination of child.

Signup and view all the flashcards

What is exit()?

A process deletes itself using this system call.

Signup and view all the flashcards

What is abort()?

Parent terminates children processes by using this system call.

Signup and view all the flashcards

What is Cascading Termination?

All children, grandchildren, etc., are terminated when process ends.

Signup and view all the flashcards

What are Cooperating Processes?

Processes that can affect or be affected by other processes.

Signup and view all the flashcards

What is Shared Memory?

Form of IPC where processes read and write shared memory.

Signup and view all the flashcards

What is Message Passing?

Form of IPC where messages are passed between processes.

Signup and view all the flashcards

What is Producer-Consumer Problem?

One process produces, another consumes that information.

Signup and view all the flashcards

What are the operations provided by IPC facility?

send(message) and receive(message).

Signup and view all the flashcards

What is Direct Communication?

Processes explicitly name each other to communicate.

Signup and view all the flashcards

What is Indirect Communication?

Messages directed and received via mailboxes/ports.

Signup and view all the flashcards

What are Operations done in Indirect Communication?

Create new mailbox (port), Send and receive messages.

Signup and view all the flashcards

What is Blocking?

Process blocked until message is received synchronously.

Signup and view all the flashcards

What is Buffering?

A queue of messages attached to the communication link.

Signup and view all the flashcards

What a Pipe?

Act as conduit letting two process communication.

Signup and view all the flashcards

What are Ordinary Pipes?

Cannot be accessed from outside.

Signup and view all the flashcards

What are Named Pipes?

Can be accessed without a parent-child relationship.

Signup and view all the flashcards

What is a Socket?

Endpoint for communication used along with IP and Port.

Signup and view all the flashcards

Study Notes

Process Concept

  • An operating system executes multiple programs as processes
  • A process is a program in execution, progressing sequentially without parallel instruction execution
  • The status of a process is indicated by the program counter's value and the processor's registers' content

Program States

  • A program is a passive entity that is stored on a disk; process is active when loaded into memory
  • Program execution starts via GUI or command line
  • A single program can have multiple processes, especially with multiple users

Process In Memory

  • Executable program code is in the text section
  • Stack is used to store temporary data when a function is invoked
  • Function parameters, return addresses, and local variables are stored in the stack
  • Data section holds global variables
  • Heap contains dynamically-allocated memory

Memory Layout of a C Program

  • Global data section has initialized and uninitialized data
  • A section is available for the argc and argv parameters passed to the main() function

Process States

  • Process state changes during execution
  • New is process creation
  • Running is instruction execution
  • Waiting is waiting for an event
  • Ready is waiting to be assigned to a processor
  • Terminated is finished execution

Process Control Block (PCB)

  • Each process is represented by a PCB, also known as a task control block
  • The process state can be new, ready, running, waiting, or halted
  • The program counter indicates the address of the next instruction
  • CPU registers vary based on computer architecture
  • Accumulators, index registers, stack pointers, and general-purpose registers are types of CPU registers
  • Condition-code information is included in CPU registers
  • State data is saved during interrupts so that the process can resume correctly when rescheduled
  • CPU scheduling data includes process priority, queue pointers, and scheduling parameters
  • Memory management information depends on the OS's memory system
  • Accounting data includes CPU time, real time used, time limits, account numbers, and process numbers
  • Information contained in PCBs include I/O devices allocated to the process and open files

Process Representation in Linux

  • The PCB is represented by the task struct in Linux
  • This structure contains necessary process information
  • Includes state, scheduling, memory management, open files, parent and child pointers, and sibling data
  • Key fields include:
    • pid_t_pid: process identifier
    • long state: state of the process
    • unsigned int time_slice: scheduling information
    • struct task_struct *parent: indicates parent process
    • struct list_head children: indicates process's children
    • struct files_struct *files: lists open files
    • struct mm_struct *mm: indicates address space
  • The long state field of task struct represents the state of the process
  • In the Linux kernel, all active processes are maintained as a doubly linked list of task structs
  • The kernel uses a pointer called current to denote the currently executing process

Process Scheduling

  • A process scheduler selects available processes for CPU core execution
  • Goal is to maximize CPU use and quickly switch processes
  • Maintains scheduling queues
    • Ready queue contains processes in main memory, ready to execute
    • Wait queues contain processes waiting for an event, like I/O
  • Processes move among various queues

Ready and Wait Queues

  • Queues are generally stored as linked lists
  • Ready-queue headers contain pointers to the first PCB
  • Each PCB includes a pointer field to the next PCB

Process Scheduling Actions

  • New processes are initially placed in the ready queue until selected for execution
  • Executing processes may encounter certain events
    • Issue an I/O request and move to the I/O wait queue
    • Create a new child process and move to a wait queue while waiting for termination
    • Can be forced off the core due to interrupts or time slice expiration, returning to the ready queue
  • Processes in waiting states return to the ready queue
  • Processes continue until termination
  • Upon termination, all queues are removed and its PCB and resources are deallocated

Context Switch

  • Interrupts cause the OS to switch the CPU core to a kernel routine
  • During an interrupt, the system saves the current process's context to restore it later
  • PCB stores the context including CPU registers, process state, and memory management data
  • Switching requires a state save and a state restore, known as a context switch

Context Switch Overhead

  • Context switch time is pure overhead because no useful work is performed
  • Switching speed depends on memory speed, register count for copying, and special instructions
  • Typical speeds are several microseconds, and are reliant on hardware support
  • Some processors provide multiple sets of registers, allowing a switch by changing the register set pointer
  • Complex operating systems increase the amount of work done during context switches

Operations on Processes

  • Operating systems functionalities include Process creation and Process Termination

Process Creation

  • Parent processes create child processes, forming a process tree
  • Processes identification are handled via a process identifier (pid)
  • Resources share options
    • Parent and children share all resources
    • Children share a subset of parent's resources
    • Parent and child share no resources
  • The execution options of a process are:
    • Parent and children execute concurrently
    • Parent waits until children terminate

Process Creation in UNIX

  • Child duplicate of parent address space
  • Child has a program loaded into it
  • fork() system call creates new processes
  • exec() system call replaces memory after fork() to load in new programs
  • wait() is called by parent, and waits for the termination of the child

Process Termination

  • Processes executes the last statement and ask the operating system to delete it using the exit() system call.
    • Status data is then sent to parent using Wait()
    • Processes’ resources are deallocated by operating system
  • Parents can terminate processes that may have exceeded the allocated resources
  • Termination occurs when task assigned to child is no longer required
  • Processes terminates if parent is exiting

Cascading Termination

  • Children are terminated if parent terminates
  • Termination is initiated by the operating system
  • Parent process may wait for termination of a child process
  • Can call wait() and receive data and pid of the terminated process

Interprocess Communication

  • Processes are either independent (cannot affect others) or cooperating (can affect others)
  • Reasons for cooperating processes include Information sharing, Computation speedup, and Modularity
  • Cooperating processes need interprocess communication (IPC)
  • Two IPC Models exist
    • Shared Memory
    • Message Passing

Communication Models

  • Shared memory allows processes to access a shared memory region to exchange data
  • Message passing involves processes exchanging messages

Producer-Consumer Problem

  • The consumer process and the producer process illustrates the paradigm for cooperating processes
  • Producer process produces information consumed by the consumer process
  • Two possible variations
    • Unbounded buffer places no practical limit on buffer size
      • Producer does not wait
      • Consumer does not wait if there is no buffer to consume
    • Bounded buffer assumes buffers are a fixed size
      • Producer wait if buffers are full
      • Consumer waits if there is no buffer to consume

Shared Memory IPC

  • Processes share a memory area to communicate
  • Communication is managed by the user processes and not the OS
  • Synchronization is needed when accessing shared memory and is detailed in chapters 6 and 7

Message Passing IPC

  • Processes communicate without using shared variables: involves send and receive calls
  • send(message)- sends a message
  • receive(message)- receives a message
  • Message sizes are dynamic or of of a fixed size

Message Passing

  • Communication requires processes to establish a communication link and exchange messages via send/receive
  • Physical Methods
    • Shared memory, hardware bus and network
  • Logical
    • Direct or indirect, synchronous or asynchronous, and Automatic or explicit buffering

Direct Communication

  • Processes name each other explicitly
    • send(P,message) sends a message to process P
    • receive(Q,message) receives a message from process Q
  • Communication link properties
    • Links are established automatically
    • Associated with one pair of process
    • One link between process
    • Links may be unidirectional or bi-directional

Indirect Communication

  • Messages are directed and received from mailboxes (aka ports) with unique IDs
  • Processes share a mailbox to communicate
  • A link is established only if processes share a common mailbox
  • A link may be linked with many processes
  • May share multiple communication links
  • Can be unidirectional or bi-directional

Indirect Communication Continued

  • The OS must Create a new mailbox (port), Send and receive messages through mailbox, and Delete a mailbox
  • Primitives
    • send(A, message) sends to mailbox A
    • receive(A, message) receives from mailbox A

Mailbox Sharing Solutions

  • Allow a link to be associated with at most two processes
  • Allow only one process at a time to execute a receive operation
  • Allow the system to randomly select the receiver and notify sender of selection

Synchronization Types

  • Blocking is the act of synchronous programming
    • Sender is block until message is received when Blocking send is in use
  • Recipient is block until a message is available when Blocking Receive is in use
  • Non-Blocking is the act of asynchronous programming
    • Sender will send a message and continue when Non-blocking send is in use
  • Recipient receives valid or null message when Non Blocking Receive is in use

Different Combination Types

  • A rendezvous (meeting) occurs when sender and recipient are blocked

Buffering

  • Messages attach to the queue of links
  • Queue of messages are zero capacity or infinite length
    • Sender must wait for receiver in zero capacity buffers
    • Sender must wait for receiver when buffer is full in bounded capacity buffers
    • Sender never waits in unbounded capacity Buffers

Pipes

  • Conduit is used to allow processes to communicate
  • The OS must handle: Unidirectional or Bidirectional communication, Two-way communication, Parent-child presence, Using them across networks
  • Ordinary Pipes
    • Unable to access processes from the outside
    • Parents calls for pipes to create children
  • Named Pipes:
    • Accessed with a parent-child relationship

Ordinary Pipes

  • Allow communication in the standard producer-consumer model
  • Treated as special files, accessed via regular read() and write() system calls in UNIX systems
  • Producer writes to the write-end, and the consumer reads from the read-end of the pipe
  • Communication is unidirectional
  • Require a parent-child relationship between processes.
  • These are called anonymous pipes in Windows

Named Pipes

  • Named pipes are bidirectional
  • Do not require a parent-child relationship between communicating programs
  • Can be used by several operations
  • Available through UNIX and Windows

Communication in Client Server Systems

  • Sockets
  • Remote Procedure Calls

Sockets

  • Communication is done through sockets defined as an endpoint
  • IP address concatenation and port, with the starting port being used to distinguish the network services
  • Socket 161.25.19.8:1625 refers to post 1625 for host 161.25.19.8
  • Communication requires a pair of sockets
  • All ports below 1024 are well known and used for standardized services
  • The loopback address 127.0.0.1 refers to to system running the process

Remote Procedure Calls (RPC)

  • RPC abstracts and manages procedure calls between networked system processes
  • Ports are used for service differentiation
  • Stubs act as a client proxy for the server's procedure and marshal the parameters
  • A server side stub then processes the incoming message by unpacking the marshall and initiating processes on the server

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Introduction to Manufacturing Training Program
10 questions
Sistemi Informativi - 1
37 questions
Operating Systems Process Concepts
37 questions

Operating Systems Process Concepts

AppreciativeElectricOrgan avatar
AppreciativeElectricOrgan
Use Quizgecko on...
Browser
Browser