Week 2 Flashcards
Process creation
A parent will create a child process and will then have control over child. E.g. Unix kernel finds init process, starts system boot, daemon processes, and terminal login processes.
Process Termination
Process asks OS to system exit or parent terminates child process. The processes resources are then removed.
Cooperating processes
Dependent upon other processes and have to communicate accordingly
Producer - Consumer
Producer generates information that will be consumed by the consumer. Process can have a bounded or unbounded buffer.
Interprocess Communication
Mechanism for processes to communicate and synchronize (direct and indirect)
Direct Communication
Processes explicitly identifies who is sending and where it is being sent. Addressing can be asymmetric, meaning they can receive from anyone by must specify who they send to
Mailboxes
Processes share a mailbox (port), which is where messages will be sent. Disadvantages: Sharing mailbox isn’t efficient.
Blocking synchronization
Synchronous message sender. Both processes must wait until the exchange is made.
Rendez-vous
Both sender and receiver are blocking. Blocker is zero capacity.
Non-Blocking synchronization
Sender can drop into buffer until receiver is ready and vice versa.
Bounded vs unbounded buffer
Bounded buffer may need to wait or abandon messages. Unbounded is very resource heavy.
Thread
Lightweight process, essentially one part of an existing process. Contains a unique stack, thread ID, and registers but shares code, memory, files, and other resources with other threads.
Benefits of threads
Less overhead on context switching. Can run on multiple CPUs. Helps responsiveness, resource sharing, faster thread creation.
What happen when a thread terminates
Rejoins main thread
Examples of threads
Games (NPCs), Web browser (tabs)
User Threads
Threads are implemented by a library. OS is not thread aware. Cooperative multitasking means there’s no interrupt when switching threads. Earliest version of threads. Process schedules threads on CPU.
User Thread advantages
Fast, don’t require system calls to switch, simple scheduling
User thread Disadvantages
No multi-processor support. When a thread is blocked, all threads are blocked.
Setup of user kernel
File and devices are manage by OS. Thread control blocks are put in data segment because OS isn’t aware of them. Stack pointers are allocated in heap or in unallocated space.
Kernel thread
Os aware thread. Os does scheduling for this thread. System calls are required to create new threads.
Kernel thread advantages
Can run a process on multiple cores. OS will block only singular threads.
Kernel thread disadvantages
Not as fast, more resource intensive
Kernel thread implementation
OS assigns stack to unallocated space automatically. Thread control blocks stored in memory.
Many-to-one implementation
User level thread. OS sees one process but programmer sees multiple threads.