Process

Process

process

process is a instance of running program.
program is command list.
All resources are distributed on a per-process basis.

process isolation

The process must be independent.
From a process perspective, you should think that a process has all of its resources and that they are all available.
The CPU splits time to ensure isolation,
Memory guarantees isolation by dividing space.

isolation
picture [1] Process isolation


One program, multiple processes

The state in which a program runs is called a process, so does one program have only one process?

The answer is yes or no.
It can be one, it can be more than two.
A program with multiple processes in one program.

data
picture [2] 1 Program with n process


Program code is held together in one program, and process-specific data is held in process units.

process elements with pcb

A process has various properties. The set of these properties is called a “Process Control Block.”

pcb
picture [3] 1 Program n process

Elements Info
Identifier process ID (PID)
State ready, running waiting …
Priority priority of process
Context data Space for backup/recovery of information
about processes immediately before/after, and after a process is passed
Memory data data
Program Counter Space to store the address of the next command to be executed
I/O status About I/O devices
Accounting infomation

context switching

Context switching is the process of implementing time-sharing
and continuously operating from the perspective of the process.

Backing up the current process status to a block of context and recovering the block of context
for the next process is called context switching when the allocated time is over.
Context switching is done by the Dispatcher(OS).

context-switching
picture [4-1] Context switching


dispatcher
picture [4-2] Dispatcher


As we checked in Overview, OS is a program.
Called when context switching is required.

process state

Process state model.
Nothing is fixed, efficiency is important.

state

picture [5] process state model


State Info
Ready The program is waiting. Process state that can be in the “Running” state
when only CPU is assigned.
Running The operational. The Ready/Waiting state occurs when the time is up,
an interrupt occurs, or other demands are required.
Waiting(=blocked) The standby state requires other resources, including the CPU.
Suspend Processes that are queued have been transferred to the HDD due to infrequently used processes or memory over due to processes.

Tables

The OS has several tables to manage the process.

tables
picture [6] Tables


Memory table

Memory table has main memory for running programs, virtual memory and protection attributes.
Virtual memory will be covered in more detail in here

I/O table

Exists to deceive that the process has a complete monopoly on I/O.
The OS needs to know the status of the I/O and the source and purpose of the I/O.
Hardware interruptions occur in I/O.

File table

The file address must be saved separately for the process to access the file and perform operations such as read/write.
It is stored separately in the file table, also known as the File Allocation Table, Each OS has its own way.
Recently, many NTFS methods have been adopted, but this is the traditional method of storing files on hard disks.

hdd
picture [7] FAT


Memory is too large to be managed per address in bytes (address).
This picture shows saving the file in blocks.
The “memo.txt” file is split into blocks and stored separately.
The OS uses FAT to find data and use files.
In Linux, it is also called a file system.

Struct of Process

Memory

The process consists largely of attributes and locations.

struct
picture [8] Process Struct


code is read-only layer. (‘text’)
Global, static, array, structure vars, and so on are stored in the data area. (+ bss)
User functions are in stack area. It gets bigger or smaller by its user functions.

phym
picture [9] Virtual memory vs Physical memory


It’s actually not saved as pretty.
Don’t be confused with the logical image.

Process creation & interrupt

A new process is created by the needs of the OS.

1. Assigns Process ID
2. Assigns memory
3. Initialize PCB
4. Link functions: win: (*.dll) linux: (*.so) ...
5. Data Structuring & Scaling

An interrupt occurs and another process is created/executed or terminated.

Interrupt includes

- exception
- interrupt (H/W)
- software interrupt (os)

The exception is an real unexpected move.
(poweroff, div with 0 etc …)

interrupt is related to hardware I/O operation.
(Print complete, timer(scheduling), etc …)

software interrupt is a call from the OS.
It usually happens when context-change or change permissions. When a software interrupt is operated by an interrupt handler(ISR), a system call (or supervisor call) operates.

Permissions: user mode vs system mode

user mode: Minimum permissions not affecting the system.
system mode: All rights on the system.

system(kernel) mode

Process Management

Process creation and termination # process isolation
Process scheduling and dispatching
Process switching # context switching
Process syncronization and support for interprocess comunication # IPC
Management of Process Control Blocks

IPC: There are times when resource sharing between processes is necessary.

Memory Management

Allocation of address space to process
Swapping
Page and segment management

Page , segment - related content will be posted here.

I/O Management

Buffer Management # buffer is the memory of devices.
Allocation of I/O channels and devices to process

Support functions

Interrupt handling
Accounting
Monitoring

Updated:

Leave a comment