When terminates goes into a Zombie state, and when another thread calls pthread_join, on the terminated thread the thread is released and the id can be reused
o
Has the following:
Execution State
Execution Stack
Static Storage of local variable
Access to the memory and resources of its process
o
Take less time to create and terminate than a process
o
Switching between threads is faster
o
Can communicate without the use of a kernel
o
User-Level Threads
o
Management done by the application
Kernel is unaware of its existence
Kernel-Level Threads – lightweight processes
Maintains context information for the process and threads
Scheduling is done on a thread basis
Advantages:
Simultaneously schedule multiple threads from the same process on multiple processors
The kernel can schedule another thread of the same process if one thread is blocked
Disadvantages
Transfer of control from one thread to another requires a switch to t he kernel (more time consuming)
o
Kernel Level vs. User Level
Kernel level are created and scheduled by the kernel and are more expensive to create.
User level threads cannot be run in parallel on multi-processor systems
Multi-Threading o
Ability of the OS to support multiple concurrent paths of execution within a single process
Context o
Setting in which execution is occurring
Deadlock o
When each process in the set is blocked awaiting an event that can only be triggered by another blocked process in the set
o
Usually involves processes competing for the same set of resources
Conditions for a deadlock
Mutual Exclusion – only one process may use a resource at a time
Hold-and-wait – may hold allocated resources while awaiting assignment of others
o
No Pre-Emption – no resource can be forcibly removed from a process holding it
Actual Deadlock
Needs previous 3 and Circular Wait – a closed chain where one process holds a resources that the next process needs
o
Dealing with Deadlock
Prevent, Avoid, Detect
Prevent Strategy –
Indirect – prevent all three of the necessary conditions occ urring at once
Direct – prevent circular waits
Avoidance
Process Initiation Denial o
Do not a start a process that may lead to a deadlock
Resource Allocation Denial o
Do not grant incremental resource requests to a process if it may lead to a deadlock
Pipes o
Circular buffer allowing two pr ocesses to communicate on the producer-consumer model
Semaphores
Signals
First-in-First-Out queue
o
Informs a process of the occurrence of asynchronous events
o
Notification sent from the software to the process, basically interrupts the process’s
normal flow of execution o
Signal Handlers catch signals
Static Linking and Loading
o
Linking – the process of collecting and combining various pieces of code and data into a single file that can be loaded into memory and executed
o
Static vs Dynamic:
Static is loaded into the program while dynamic is hooked into the program but isn’t actually in the program
Dynamic Produces a smaller executable
Hard Links vs. Soft Links o
Hard links cannot point to a directory, it is directly t ied to something and contains everything it points to
o
Compilation o
Soft Links point to the file like a pointer does in C Four steps
Executing the preprocessor
Compiling the C code into Assembly Language
Compiling the Assembly Code into Object Code
Linking the Object Code to create an Executable File
Libraries o
A File containing several objective files
o
Can use an entire library as a single entity when linking a program
o
Static:
o
Linked into the programming during the linking phase of compilation
Inserts the objective files from the static library into the executable
Shared/Dynamic:
During compile time the compiler m akes sure the library is linked properly
During execution they are loaded into memory and attaches them to a copy of the program in memory
o
Pre-relocation – relocate libraries ahead of time
o
Limited Sharing – relocate separately for each process
o
Position Independent Code – no need for relocation
BIOS o
Basic Input/Output System
o
Three primary functions
Power on self test
Load and transfer control to boot program
Provide drivers to all devices
Memory Tables o
Non-Volatile RAM
Used to keep track of main and secondary memory
File Tables o
Provide information about
Existence of files
Location in secondary memory
Current Status
Other attributes
Process Tables o
o
Know details:
Current State
PID
Location in Memory
Process Control Block
Modes of Execution o
User Mode – less privileged
o
System Mode – kernel level
Scheduling o
Dynamic:
Process Image – collect of program: data, stack and attributes
Priorities are scheduled during execution
System Types: o
Multi-Programming Batch Systems
Execute multiple jobs concurrently, sharing processor time between the executing jobs
o
Time-Sharing Systems
o
Sharing the computing resources among many users
Share Servers
Same as multi-programmed batch systems now-a-days
Share a single computer’s processing time among many clients
o
Real Time Systems
o
Strategies:
First-In-First-Out
Single job queue
Each job runs to completion
Shortest-Job-First
Chooses the job with the shortest remaining execution time
Round-Robin Queue
Each process is executed for a quantum amount of time, interrupts the process, moves the process to the end of the queue and selects the process at the front of the queue o
Favors shorter processes
Multi-Level Feedback Queue
Prioritized Queue or several queues with different priorities
Run each for a quantum amount of time, and lower the priority of the process until it reaches the lowest priority
Virtual Machines o
Efficient, isolated duplicate of a real machine
o
A means for structuring an operating system
Virtual Machine Monitor (VMM) o
Runs in privileged modes
o
Used to multiplex system resources
File System o
Easy-to-use permanent storage
o
Needs:
o
Directories
File Access
Criteria
Easy Access
High Performance
Permanence
Security
Disk Read/Write Steps o
Position The read/write head over the correct cylinder
o
Rotate the disk platter until the desired sector is underneath the read/write head
o
Rotate the disk platter so the head can read/write the entire sector
Reducing Seek Time o
Keep related things close to one another
o
Separate unrelated thing
Crashing o
How to Cope
Don’t Crash
Perform multi-step disk updates in an order such that the disk is always consistent Consistency Preserving Approach
o
Perform multi-step disk updates as Transactions
Transactional Approach
Treats a series of file system updates as Atomic Transactions
Atomic
Consistent
Isolated
Durable
Two Types
Journaling o
Record previous contents (undo journaling)
o
Record New contents
o
Keeps track of changes, it is a circ ular log in case there is a crash these things will be more easier to bring back and less likely to be corrupted
Shadow Paging o
Steps of transaction written to disk, but old values remain
o
Single write switches old state to new
Virtual Memory o
Paging – divide the address space into fixed-size pages
Mapping virtual addresses into real addresses
Page
A page of Virtual Memory
Page Frame
Subdivision of primary memory
o
Segmentation – divide the address space into variable size segments
o
Performance
o
Trap Occurs (page fault)
Find free page frame
Write page out if no free page frame
Fetch Page
Return from Trap
Global vs Location allocation
Global – all processes compete for page frames from a single pool
Local
Each process has its own private pool of page frames