1/31
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Process Scheduler
Selects among available processes for next execution on CPU
Maximizes CPU use
Join() System Call
Suspension: The parent process or main thread pauses execution.
Waiting: It waits until a specific child or thread finishes task.
Resumption: Once the child exits or terminates, the parent collects its exit status and resumes
Context Switch
When the CPU switches from one process to another
Must save the state of the old process and then load the saved state for the new process

Child process
Created from the parent process
If one has an error then parent aborts one without shutting down the whole system
Inherits:
Shared memory segments
Environment variables
Parent resources
Fork() System Call
Creates a new process splitting from the parent
Exec() System Call
Used after fork() to replace the process’ memory space with a new program
Replaces the current program's code, data, heap, and stack with those of the new program.
The process itself remains, including its PID and other process-level attributes
Abort() System Call
Parent can terminate the execution of children process using this system call
Reasons:
Child has exceeded allocated resouces
Task assigned to child is not required anymore
The parent is exiting children can’t exist on their own
Cascading Termincation
All children and grandchildren are terminated
Initiated by OS
Shared Memory (IPC)
An area of memory is used among the process that need to communicate
Under control of the users’ process not the OS
They need to synchronize their actions so they don’t write to the same location
Message Passing (IPC)
Processes communicate with each other without sharing variables
Provides send(message) and receive(message) operations
Message size is either fixed or variable
Race Condition
Happens when multiple processes or threads access and change shared data at the same time
What can happen:
Data corruption
Security Risks
Hackers can exploit timing gaps
Direct Communication
For processes to communicate with each other they must name each other explicitly
send(P, message) - send a message to process P
receive(Q, message) - receive a message from process Q
Communication links are established automatically
There’s only 1 link between a pair of processes
Indirect Communication
Messages between processes are directed and received from mailboxes (also known as ports)
Mailbox has unique ID
send(A, message) - send a message to mailbox A
receive(A, message) - receive a message from mailboxes A
Communication
Communication link established only if processes share a common mailbox
A link can be associated with many processes
Link can be uni-directional or bi-directional
Blocking Message Passing
Message passing may be either blocking or non-blocking
Synchronous
Send - the sender is blocked until the message is received
Receive - the receiver is blocked until a message is available
If both send and receive are blocking then its a rendezvous!
Non-blocking Message Passing
Message passing may be either blocking or non-blocking
Asynchronous
Send
The sender sends the message and continues
Receive
The receiver receives:
A valid message or
A null message
Multi-threaded Benefits
Responsiveness
May allow continued execution if part of process is blocked
Resource Sharing
Threads share resources of process
Economy
Cheaper than process creation, thread switching
Scalability
Process can take advantage of multicore architectures
Threads
The smallest unit of execution within a process
While a process holds the application’s memory and resources, this handles the actual execution
Contains:
Tracks the next instruction to run
Holds current working variables
Switching between these takes less time than a full process
Multicore Programming
Puts pressure on programmers with challenges such as:
Dividing activities
Balance
Data Splitting
Testing and Debugging
Can be used to speed up evaluations by separating parts to other cores
Parallelism
Implies a system can preform more than one task simultaneously
Multi-core system
Data Parallelism
A type of parallelism
Distributes subsets of the same data across multiple cores (same operation on each)
Task Parallelism
A type of parallelism
Distributes threads across cores, each thread performing unique operation
Concurrency
Supports more than one task making progress by sharing single processor resources
Single Processor / core
Amdahl’s Law
Identifies performance gains from adding additional cores to an application that has serial and parallel components
S is serial portion
N is processing cores

User Threads
A thread of execution managed entirely by application-level thread libraries in user space.
OS kernel unaware of existence
Kernel Threads
A basic unit of execution that is managed directly by the OS kernel
Asynchronous Thread Cancellation
Terminates the target thread immediately
Deferred Thread Cancellation (or Synchronous)
Allows the target thread to periodically check if it should be cancelled
1-to-1 Multithreading Model
Each user-level thread maps to kernel thread
Advantages:
True parallelism
Non-blocking: other threads keep running if another is blocking
Maximizes performance on multi-core processors
Disadvantages:
High overhead: A lot of memory and time is used
Resource limits: kernel management takes more resources
Zombie Process
A terminated child process that remains in the process table because it’s parent. process has not yet read it’s exit status
Orphan Process
A running child process whose parent process has finished, crashed, or terminated before the child finished execution
Many-to-Many Multithreaded Model
Many user-level threads to an equal or smaller number of kernel-level threads\
Benefits:
Can create as many user threads as needed and the system maps them to kernel threads
Efficiency: Avoids heavy kernel overhead since management happens mostly in user space
Disadvantages:
Complex Implementation
Scheduling overhead
Many-to-1 Multithreading Model
Maps many user-level threads to a single kernel-level thread
Advantages:
Thread switching and management is very fast because they avoid system calls
Low Overhead
Disadvantages:
If one user-thread is waiting for input then the entire process stops
No true parallelism