Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views12 pages

Process Concept - Unit 1

The document provides an overview of process concepts, including process states, operations, and scheduling in operating systems. It explains the distinction between independent and cooperating processes, as well as the role of threads, their types, and benefits. Additionally, it covers thread scheduling, communication, synchronization, and the importance of thread safety in multi-threaded programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

Process Concept - Unit 1

The document provides an overview of process concepts, including process states, operations, and scheduling in operating systems. It explains the distinction between independent and cooperating processes, as well as the role of threads, their types, and benefits. Additionally, it covers thread scheduling, communication, synchronization, and the importance of thread safety in multi-threaded programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

I UNIT

• Process concepts and scheduling


• Operations on processes
• Cooperating Processes
• Threads
Process Concepts
• Earlier only 1 program is executed at a time.
• Today, Multiple programs loaded into memory and execute concurrently.
• PROCESS: Program under execution.
• It is the unit of work done in the modern TS s/m.

System
• Context switching: CPU is switched between processes Processes
to make computer more productive. Save the current
process status and restore the process status.
OS processes User processes
executing s/m executing user
code code
• Text Section: Compiled program code read from non-volatile max

STACK
storage.

• Data Section: Stores the global and static variables allocated and

initialized prior to executing main.

• Heap: Used for dynamic m/y locations.


HEAP
Managed via calls(new, delete, malloc, free etc.)
DATA
• Stack: Used for local variables.
TEXT
Assigned, used & freed up when variable go out of scope. 0
Process in M/Y
PROCESS STATES(imp)

 When process executes , its state


changes.
1. NEW: Process being created.
2. RUNNING: Instruction being executed.
3. READY: Process waiting to be assigned to
the processor
4. WAITING: Waiting for some event to occur
(I /O completion or reception signal).
5. TERMINATED: Process execution
completed.
OPERATIONS ON PROCESSES
Process Creation: Process termination
1. User request for process creation. A process 1.After the process has completed the
may be created by another process using fork(). execution of its last instruction, it is terminated.

2. Process pre-emption 2. The resources held by a process are released


after it is terminated.

3. Process Blocking 3. A child process can be terminated by its


parent process if its task is no longer relevant.

4. The child process sends its status information


to the parent process before it terminates.

5. When a parent process is terminated, its


child processes are terminated as well as the
child processes cannot run if the parent
processes are terminated.(cascading
termination).
PROCESS CONTROL BLOCK / TASK
CONTROL BLOCK(IMP)
• Data structure used by an operating system (OS) to
manage and control the execution of processes.
1. PROCESS STATE:
2. PROCESS No.: Unique identifier given to process.
3. Program Counter: Stores the address of next instruction to be executed.
4. CPU Registers: Includes accumulators, index registers, stack pointers,
general purpose registers.
5. Memory limits: This field contains the information about memory
management system used by the operating system. This may include
page tables, segment tables, etc.
6. Open files list : This information includes the list of files opened for a
process.
PCB works as a repository for any information for the process.
PROCESS
SCHEDULING
1. SCHEDULING QUEUES
2. SCHEDULERS
3. CONTEXT SWITCHING
SCHEDULING QUEUES:
• JOB QUEUE: The place where
processes are placed when they
enter the system.
• READY QUEUE: Place where
processes that are in the main
memory and are ready and waiting to
execute are kept. Stored as linked
list.
• DEVICE QUEUE: Processes waiting
for a particular I/O devices are stored
here. Each device has its own device
queue.
2. SCHEDULERS: Special system s/w that handles process scheduling in diff. ways. (IMP)
• 3 types:
1. Long-term scheduler 2. Medium-term scheduler 3. Short-term scheduler
Basis Short-Term Medium-term Long-Term
Scheduler Scheduler Scheduler
1. Alternate Name It is also called a CPU scheduler. It is also called a process swapping It is also called a job scheduler.
scheduler.

2. Degree in It provides lesser control over the It reduces the control over the degree It controls the degree of
programming degree of multiprogramming. of multiprogramming. multiprogramming.

3. Speed The speed of the short-term Speed of medium scheduler between The speed of a long-term term
scheduler is very fast. the short-term and long-term scheduler is more than medium-
scheduler term scheduler.

4. Usage in time- sharing It is maximum in the time-sharing It is a part of the time-sharing system. It is almost absent or minimal in a
system. system. sharing system.

5. Purpose It selects the processes from among It can reintroduce the from among the It selects processes from the pool
the process that is ready to execute. process into memory that executes and and loads them into memory for
its execution can be continued. execution.

6. Process state Process state is ready to running Process state is not present Process state is new to ready.

7. Selection of process Select a new process for a CPU quite Select that process, which is currently Select a good process , mix of I/O
frequently. not need to load fully on RAM, so it bound and CPU bound.
swap it into swap partition.
COOPERATING PROCESSES
 2 types of processes:
1. Independent Process: Independent Processes are those processes whose task is not dependent on any other
processes.
2. Cooperating Process: Cooperating Processes are those processes that depend on other processes or
processes.
• They work together to achieve a common task in an operating system.
• These processes interact with each other by sharing the resources such as CPU, memory, and I/O devices
to complete the task.
• Inter-Process Communication (IPC)
• Concurrent execution
• Resource sharing
• Deadlocks
• Process scheduling
THREADS
• Threads are the smallest unit of execution within a process managed by an operating system. They allow a
program to perform multiple tasks.
• DEFINITION: A thread is a basic unit of CPU utilization, representing a single sequence of execution within a
process.
• Threads share the same memory space and resources within a process, including code, data, and open files.
• Each thread has its own program counter, stack, and set of registers.
• BENEFITS:
• Responsiveness: Threads enable responsive user interfaces by allowing tasks such as user input
handling and GUI updates to run concurrently with other processing.
• Resource Sharing: Threads within the same process can easily share data and resources, leading to
efficient communication and coordination.
• Scalability: Threads provide a lightweight mechanism for concurrent execution, allowing programs to
take advantage of multiple CPU cores and scale performance on multi-core systems.
• Concurrency: Threads allow programs to achieve concurrency, enabling multiple tasks to execute
simultaneously. While processes provide isolation and protection by running in separate memory
spaces, threads within a process share memory, allowing them to communicate and coordinate more
efficiently.
TYPES OF THREADS:
• User-Level Threads (ULTs): Managed entirely by the application without kernel
support. ULTs are lightweight and provide flexibility but may suffer from limited
concurrency and blocking issues.
• Kernel-Level Threads (KLTs): Managed by the operating system kernel. KLTs offer
better concurrency and scheduling control but may incur higher overhead due to
kernel involvement.
THREAD STATES:
• Running: The thread is currently executing on the CPU.
• Ready: The thread is ready to execute but waiting for CPU time.
• Blocked: The thread is unable to execute due to waiting for an event (e.g., I/O
operation, lock acquisition).
THREAD SCHEDULING:
• The operating system's scheduler is responsible for allocating CPU time to threads.
• Scheduling policies determine the order in which threads are executed and how CPU
resources are distributed among them.
• Common scheduling algorithms include round-robin, priority-based, and multilevel
feedback queues.

Thread Communication and Synchronization:


• Threads within a process often need to communicate and synchronize their activities
to avoid data races and ensure consistency .
• OS provide synchronization mechanisms such as locks, mutexes, semaphores, and
condition variables to coordinate access to shared resources and enable inter-thread
communication.

Thread Safety:
• Programs with multiple threads must ensure thread safety to prevent data corruption
and race conditions.
• Thread-safe programming techniques include using synchronization primitives,
atomic operations, and immutable data structures to protect shared resources and
avoid concurrent access issues.

You might also like