1/50
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
proccess
a program in execution
Program counter
specifying the next instruction to execute and a set of associated resources
proccess text section
the executable code
Process - Data Section
global variables
Process - Heap section
memory that is dynamically allocated during run time
Process - Stack Section
temp data storage when invoking functions, parameters and local varables p
Process State - New
the Process is being created
Process State - Running
Instruction of the process are being executed
Process State - Waiting
The process is waitign for some event to occur such as an IO event
Process State - Ready
The process is waiting to be assigned to the CPU (to run)
Process State - Terminated
The process has finished execution or forced to terminate
Process Block Cotrol
a data structure used by the operating system to store information about a process
proccess state
ID
proccess counter
cpu register
cpu scheduling
Process Scheduling
method by which the operating system determines which process should run at any given time
Process Scheduling Queues
As processes enter the system, they are put into a ready queue. the queue doesnt move, the pointer does SHORT TERM SCHEDULING
Swapping
intermediate form of scheduling used in some operating systems to manage memory. It involves temporarily removing a process from memory and saving its state to disk, and later reintroducing it back into memory when needed.
Long Term Scheduling
(also known as Job Scheduling) is responsible for managing the admission of processes into the system for execution. It decides which processes should be moved from the new queue to the ready queue based on system conditions and resource availability.
Context Switch
also known as Process Switching, occurs when the CPU switches from executing one process to another
EXAMPLE
Interrupt: The CPU is interrupted during Process 0’s execution (hardware/software interrupt).
Save State: Process 0’s state is saved in its PCB0 (registers, program counter, memory context).
Idle Process: Process 0 is idle and placed in the queue.
Load State: The state of Process 1 is loaded from PCB1.
Execution: Process 1 is executed.
Repeat: After Process 1 finishes, the process repeats for Process 0.
process creation
fork() returns the child PID, can wither share all info, some or none. the child can either be the duplicate of the parent or a new program laded into it. 2 ^n -1 child processes
wait()
the parent waits until the child is done to contiue to execute, with out this the child and parent execute concurently
exec()
used after a fork() to replace the existing proccess and start with a new program
pid > 0
parent processch
pid == 0
child process
proccess creation - windows API
CreateProcess()
orphan process
the parent porcess is abort() when the child is running
zombie process
the parent calls fork() with out using wait() ssytem call
Interprocess Communication(IPC)
mechanisms that allow processes to communicate and share data with each other within an operating system
Independent Process
doesnt share data with any other process
Cooperating process
can affect or be affected by the other processes executing in the system (shares data with other processes).
IPC Shared Memory
typically faster than message passing – initial system call only to established the shared memory segment, afterward it can be accessed in user mode
IPC Message Passing
all communication use system call (continuous kernel intervention can slow down the performance) easier to implement, need send()/recive() to implement a link
IPC in message-passing - Direct Communication Symmetry
processes must name each other explicitly: send (P, message) – Send a message to process P. receive(Q, message) – Receive a message from process Q.This scheme exhibits symmetry in addressing.
IPC in message-passing - Direct Communication Asymmetry
send (P, message) – Send a message to process P. receive(id, message) – Receive a message from any process.
IPC in message-passing - Indirect Communication
Messages are sent to and received mailboxes or ports. send (A, message) – Send a message to mailbox A. receive(A, message) – Receive a message from mailbox A.
IPC in message-passing - Synchronization - Blocking/synch message passing
ensures that processes coordinate effectively when sending and receiving messages. This prevents issues like race conditions, data inconsistencies, or deadlocks.
Blocking send.
The sending process is blocked until the message is received by the receiving process or by the mailbox
Blocking receive.
The receiver blocks until a message is available.
Non blocking
asynchronous, allows a process to send or receive a message without waiting for the other process to be ready. In other words, the sender doesn't pause or wait for the receiver to acknowledge the message
Non-blocking send
the sender sends the message and return before the delivery of the message (will not wait for a confirmation)
Non-blocking receive
the receiver receives a valid message, or a null.
IPC in message-passing - Buffering
Whether communication is direct or indirect, messages exchanged by communicating processes reside in a temporary queue.
IPC in message-passing - Buffering - Zero capacity
no quue existing
IPC in message-passing - Buffering - Bounded Capacity
queu length n If the queue is not full when a new message is sent, the message is placed in the queue, and the sender can continue execution without waiting.
IPC in message-passing - Buffering - Unbounded Capacity
the queue's length is potentially infinite; thus, any number of messages can wait in it. The sender never blocks.
Ordinary Pipes
Unidirectional communication, typically used in a parent-child process relationship for communication within the same machine.
Issues with Pipes
Bidirectional or unidirectional communication.
Half-duplex or full-duplex communication.
Parent-child relationship.
Producer-Consumer Model
The producer writes to the pipe's write end, and the consumer reads from the read end. Pipes are unidirectional, but two pipes can be used for bidirectional communication.
pipe() Function
pipe(int fd[])
creates a pipe with two file descriptors: fd[0]
for reading and fd[1]
for writing. This is used for communication between a parent and child process.
Reading and Writing with Pipes
Parent writes: write(fd[1], dataBuf, count)
Child reads: read(fd[0], dataBuf, count)
This allows communication between the two processes using the pipe.
Named Pipes (FIFOs)
More powerful than ordinary pipes, allowing bidirectional communication without a parent-child relationship.
Sockets
socket is an endpoint for communication in a network. A pair of processes communicating over a network use a pair of sockets, identified by an IP address and port number.