Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Process Control Blocks: Where Operating Systems Store Process Information, Lecture notes of Process Control

An in-depth look into process control blocks (pcbs), which are essential components of operating systems. Pcbs contain all the necessary information about a process, including memory usage, open files, devices, process state, priority, and more. Pcb structures in unix, linux, and windows nt, as well as process creation and states.

What you will learn

  • How does the operating system manage memory for processes using PCBs?
  • What are the differences between PCB structures in UNIX, Linux, and Windows NT?
  • What information is stored in a Process Control Block (PCB) in an operating system?

Typology: Lecture notes

2021/2022

Uploaded on 09/27/2022

gorillaz
gorillaz 🇬🇧

3.8

(5)

219 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Operating Systems Lecture 06 page
Process Control Blocks
PCBs
Where the OS can find all the information it needs to know
about a process.
memory
open streams/files
devices, including abstract ones like windows
links to condition handlers (signals)
processor registers (single thread)
process identification
process state - including waiting information
priority
owner
which processor
links to other processes (parent, children)
process group
resource limits/usage
access rights
process result - may be waited for by another process
Doesn't have to be kept together !
Different information is required at different times
UNIX for example has two separate places in memory with
this information. One of them is in the kernel the other is
in user space. Windows does the same.
Operating Systems Lecture 06 page
Linux PCBs
In the same order as the previous slide.
/* memory management info */ !
struct mm_struct *mm;
/* open file information */ !
struct files_struct *files;
/* tss for this task */ !
struct thread_struct tss;
int pid;
volatile long state; /* -1 unrunnable, 0
runnable, >0 stopped */
long priority;
unsigned short uid,euid,suid,fsuid;
#ifdef __SMP__ !
int processor; !
#endif
struct task_struct *p_opptr, *p_pptr,
*p_cptr, *p_ysptr, *p_osptr;
/* limits */ !
struct rlimit rlim[RLIM_NLIMITS]; !
long utime, stime, cutime, cstime,
start_time;
2
Operating Systems Lecture 06 page
UNIX process parts
The PCB is the box labelled process structure
but the user structure maintains some of
the information as well (only required when
the process is resident).
3
Operating Systems Lecture 06 page
Windows NT PCBs
Information is scattered in a variety of objects.
Executive Process Block (EPROCESS)
includes
KPROCESS and PEB
pid and ppid (the ppid is not visible to Win32)
file name of program
window station - the screen or remote terminal
exit status
create and exit times
links to next process
memory quotas
memory management info
Ports for exceptions and debugging
Security information
4
pf3
pf4

Partial preview of the text

Download Process Control Blocks: Where Operating Systems Store Process Information and more Lecture notes Process Control in PDF only on Docsity!

Operating Systems Lecture 06 page

Process Control Blocks

PCBs

Where the OS can find all the information it needs to know about a process.

  • memory
  • open streams/files
  • devices, including abstract ones like windows
  • links to condition handlers (signals)
  • processor registers (single thread)
  • process identification
  • process state - including waiting information
  • priority
  • owner
  • which processor
  • links to other processes (parent, children)
  • process group
  • resource limits/usage
  • access rights
  • process result - may be waited for by another process Doesn't have to be kept together Different information is required at different times UNIX for example has two separate places in memory with this information. One of them is in the kernel the other is in user space. Windows does the same. Operating Systems Lecture 06 page

Linux PCBs

In the same order as the previous slide.

/* memory management info */ struct mm_struct mm; / open file information */ struct files_struct files; / tss for this task / struct thread_struct tss; int pid; volatile long state; / -1 unrunnable, 0 runnable, >0 stopped */ long priority; unsigned short uid,euid,suid,fsuid; #ifdef SMP int processor; #endif struct task_struct *p_opptr, *p_pptr, *p_cptr, *p_ysptr, p_osptr; / limits */ struct rlimit rlim[RLIM_NLIMITS]; long utime, stime, cutime, cstime, start_time; 2

UNIX process parts

The PCB is the box labelled process structure

but the user structure maintains some of

the information as well (only required when

the process is resident).

Windows NT PCBs

Information is scattered in a variety of objects.

Executive Process Block (EPROCESS)

includes

  • KPROCESS and PEB
  • pid and ppid (the ppid is not visible to Win32)
  • file name of program
  • window station - the screen or remote terminal
  • exit status
  • create and exit times
  • links to next process
  • memory quotas
  • memory management info
  • Ports for exceptions and debugging
  • Security information

Operating Systems Lecture 06 page

NT PCB (cont.)

Kernel Process Block ( KPROCESS ) includes

info the kernel needs to schedule threads

  • Kernel and user times.
  • Pointers to threads.
  • Priority information.
  • Process state
  • Processor affinity

Process Environment Block ( PEB ) includes

info which needs to be writable in user

mode

  • image info: base address, version numbers, module list
  • heaps (blocks of one or more pages) 5 Operating Systems Lecture 06 page

Process table and Thread structures

Process Table

A collection of PCBs Commonly an array of pointers to PCBs

Thread structures (like PCBs)

  • private memory (runtime stack) and static storage for local variables
  • processor registers
  • thread identification
  • thread state - including waiting information
  • priority
  • processor
  • associated process
  • thread group
  • thread result - maybe waited for by another thread 6

Process states

At its simplest a process is either running or it

is not.

Java thread states

Being created

Different methods of creating processes

• create process system call - takes a program

name or a stream with the program data

• copy process system call - a strange way of

doing it but is now very widespread thanks

to UNIX

• create a new terminal session

Operating Systems Lecture 06 page

Two solutions

1. copy on write

No copy is made at first. The data pages of the parent process are set to read only. If a write occurs the resulting exception makes a copy of the page for the other process – both copies are then marked writable.

1. vfork

Trust the programmers to know what they are doing.

With vfork - parent process blocks until child

finishes or calls exec.

How many calls to ps are created by the earlier code if we could use vfork?

Copy on write is the predominant strategy.

It is used in many situations to improve throughput. 13 Operating Systems Lecture 06 page

NT process creation

  • open .exe file and create a section object (actually quite complex because of the different subsystems)
  • create NT process object
  • Set up EPROCESS block
  • create initial address space
  • create KPROCESS block
  • finish setting up address space - including mapping the section object
  • adds process block to the end of the list of active processes
  • set up PEB
  • creates initial thread (initially suspended)
  • Win32 subsystem is notified about the new process (includes the arrow and hourglass cursor)
  • initial thread starts
  • goes through more startup in the context of the new process - includes loading and initializing DLLs 14 Operating Systems Lecture 06 page

Before next time

Read from the textbook

3.2 Process Scheduling 3.3 Operations on Processes 15