week 5 - L1 - Process management Flashcards

1
Q

process

  • what is a process
  • what does it consist of
A

Process

  • A process is a running program ( also unit of execution)
  • It is the instantiation of a program.
  • It consists of code and the data, in memory to run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

serial processing

  • does it have an OS?
  • what do the machines need to run?
  • what’s the setup for it?
A

Serial processing
- No operating system

  • Machines run from a console with display lights, input device, and printer
    o Display lights – error messages
    o Input device – punch card, tape
    o Printer – output
  • Setup included loading and compiling the program, and loading and linking common functions – very time consuming (errors!)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Uniprogramming

  • what must the processor do?
  • how does it work?
A
  • Processor must wait for the I/O instruction to complete before proceeding
  • We can see that the way the program works is it runs then waits for instructions, then runs and wait for instructions… and so on

RUN _ WAIT RUN _ WAIT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Simple batch Systems

  • what does the user do?
  • how does the user prepare jobs?
  • what happens to jobs with similar requirements
  • what are the steps?
A

The user doesn’t interact with the system directly.

The user prepares jobs using an offline device to punch cards.

Jobs with similar requirements are batched together as a group.

  • Resident monitor program: scheduling, privileged operations
  • Users submit jobs to operate
  • Operator batches jobs
  • Monitor controls a sequence of events to process batch
  • When one job is finished the control returns to Monitor which reads next job
  • Monitor handles scheduling (FIFO aka first in first out)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

multiprogramming

  • what does the processor do?
  • what does the sequence in which programs are executed depend on?
  • what can happen after an interrupt handler completes? and what does it depend on
A

Multiprogramming
- As the name indicated, the processor has more than one process to execute

  • The sequence in which programs are executed depends on
    o Their relative priority
    o Whether they are waiting for I/O(input/output)
  • After an interrupt handler completes, the control MAY NOT RETURN to the program that was executing at the time of the interrupt
    o (depending on the scheduling)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Time sharing systems

  • what does it use to handle multiple jobs?
  • what happens with the processor time?
  • how do multiple users access the system? through what?
A
  • Time sharing system uses multiprogramming to handle multiple interactive jobs
  • The processor’s time is shared between multiple users
  • Also multiple users simultaneously access the system through terminals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

process

- what does it contain?

A

A process contains:
- Address space
o Code and data for running the program

-	CPU state
o	Program counter(PC) pointing to the next instruction 
o	Stack pointer (SP)
o      PC and ST
o	General purpose register values
-	Set of resources
o	files
o	network connections 
o	other hardware resources 
-	A program is a piece of code, while a process is a dynamic instance of a program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Process address space

  • what is it made of?
  • what do each of them contain?
A

STACK – stores temporary data such as method parameters, method return addresses and local variables

HEAP – is dynamically allocated memory to a process while it is running
- The memory is deallocated when the process stops running

STATIC DATA – section stores static variables
- i.e. a variable that has been allocated statically

PROGRAM COUNTER (PC) – is a CPU register that points to the next instructions to be fetched and executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Process control block (PCB)

  • what is it?
  • what does it use to uniquely identify processes?
  • what does it keep when the process is not running?
  • is it the same in different systems?
  • how many fields can it have in Linux?
  • what are they?
A
  • in order to keep track of a process state the CPU maintains data structure called process control block PCB which stores information about it
  • processes are identified by an unique integer process ID called PID
  • the PCB is used to keep all the process execution state when it’s not running (so basically PC, SP, register values etc)
    o i.e. PC, SP, register values etc
  • the PCB is the representation of a process used by OS

o it can very in different operating systems

  • PCB is a data structure with many fields (in Linux there are over 95 defined in task struct)
  • The main fields are:
    o Process ID (PID)
    o Parent process ID (PPID) – pointer to parent process
    o Process state (ready, running, waiting etc)
    o Pointers for state queues
    o PC, SP, register current values
    o Address space information
    o Process privileges (i.e. allow access to system resources)
    o CPU scheduling information (priority)
    o Memory management information
    o Accounting information(CPU time for process execution, time limits etc.)
    o IO status information (list of I/O devices allocated to the process)
    o User ID(Linux)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Context Switching

  • what values does the CPU currently contain?
  • what is it?
  • how does it work?
  • what is scheduling?
  • who controls context switching?
A
-	When a process is running, the CPU contains the current values for:
o	PC (program counter)
o	SP (stack pointer)
o	And other registers
  • Control switching is the act of switching the CPU from one process to another
  • To do this it saves the CPU state of running process in its PCB
  • When the OS returns the process to the running state, it loads the CPU registers with values stored in the process PCB
  • SCHEDULING is the task of choosing which process to run next
    o So the context switching is controlled by the scheduler
  • The concept of multi-processing revolves around context switching which allows more than one task (process) to run at the same time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

process control

- what are the steps of creating a process?

A

Process control

a unique identifier is assigned to the new process
memory is allocated to it
the PCB is constructed and initialised
the PCB is placed in te queue
other OS modules are notified about the process

The process of creating a process step by step:

  1. A unique identifier is assigned to the new process
    a. One new entry is added to the primary process table
  2. Memory is allocated for the process
    a. Includes program, data, stack and PCB
  3. The PCB is constructed and initialised
    a. ID, state = “ready”, CPU state = empty, resources = none
  4. The PCB is placed in the queue (which is a linked list)
  5. Other O/S modules are notified about the new process
    a. And create or expand other data structures to accommodate info about the new process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Event that trigger O/S switch processes

  • what are the 2 main events?
  • examples of some?
  • how do they differ?
A

interrupts and traps

  • Interrupts – external, asynchronous events, independent of the currently executed process instructions
    o Clock interrupts
     O/S checks time and may block process

o I/O interrupts
 Data has come, O/S may unblock process

o Memory fault
 O/S may block process that must wait for a missing page in memory to be swapped in

  • Traps
    o exceptions – internal, involuntary synchronous events caused by instructions
     O/S may terminate or recover a process

o System calls – internal, voluntary synchronous events calling a specific O/S service

 After service completed, O/S may either resume or block the calling process depending on I/O, priorities, etc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Process life cycle

  • what are the steps of a process?
  • how are disk drives compared to CPU speeds?
A
  • Processes are created(born), carry out tasks, go to sleep, die (or get killed)
  • They may differ from OS to OS but in general they are in on of the following states:
  • Start – initial state when process is created
  • Ready – process is waiting to be assigned a CPU
  • Running – the process is assigned a CPU by the OS scheduler and instructions are being executed
  • Waiting – the process is waiting for the physical things to happen such as a bloc of dish drive data to become ready
  • Terminated or exit (the process has finished its task and is placed in the terminated state by the OS where it waits to be removed from memory)

o Disk drives are slow compared to CPU speeds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

process scheduling types

  • what are the 3 types?
  • how are they different?
A

Process scheduling types

  • Long term scheduling (job scheduler)
    o Define which processes are admitted to the system
  • Medium term scheduling
    o Part of the swapping function
  • Short term scheduling
    o Which process has control of the CPU
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
short term scheduling 
- what is the aim of it?
- what happens sometimes when we want to optimise aspects of system behavior?
- what is the trade of switching?
-
A

Short term scheduling
- Aim is to allocate processor time in order to optimize one or more aspects of system behaviour

  • Sometimes this includes pre-emptively switching processes
    o OS takes CPU control from one process and allocates it to another
    o Basically moves control of CPU from one process to another
  • Every time processes switch, there is an overhead, while the dispatcher runs
    o Basically a trade-off, because there is overhead. Some things need to be saved so time/resources are wasted on that and other things
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Scheduling criteria

- what are the 2 types?

A

User-oriented criteria
- Relate to the behaviour of the system as perceived by the user or process
o Such as response time in an interactive system

  • Important on virtually all systems
  • Some of the indexes for the user-oriented criteria are
    o Turnaround time
    o Response time
    o Deadlines
    o Predictability

System oriented criteria
- Focus on efficient and effective utilization of the processor (rate at which the processes are completed)
- Generally of minor importance on single-user systems
- Some of the indexes for the system-oriented criteria are
o Throughput
o Processor utilisation
o Fairness
o Enforcing priorities
o Balancing resources

17
Q

scheduling algorithms

  • what can’t the algorithm do?
  • what are the parts to an algorithm? (what does it need to take into consideration)
A

Scheduling algorithms

1
- The algorithm can not optimise for all the criteria
o So balance is key
- There are many different algorithms

2
- There are 2 parts to a scheduling algorithm
o Which process to run next
o When to change

18
Q

First-come-first-served FCFS

  • what is it also called
  • where are processes added when they arrive
  • which process has access to the CPU first
  • how does it sort
  • problems with FCFS
A

First-come-first-served (FCFS)
- Simplest scheduling algorithm
- Often called first in first out (FIFO)
o Processes are added to a ready queue as they arrive
o When a process leaves CPU, the process that has been in the queue for the longest gets the CPU

Problems with FCFS
-	Easy to implement
-	Not very fair
o	One big process could “hog” the CPU
	Like there’s 10 people in the queue waiting to be server with food, the first one orders a ton of food and it’s not fair for the others who ordered a banana bread to wait that long 
o	I/O- bound processes suffer
19
Q

shortest job first SJF algorithms

  • what does it assume
  • which processes are picked first?
  • problems with it
A

Shortest job first (SJF)

Scheduling in batch systems

  • Non pre-emptive, assumes the run times are known in advance
  • When there are several equally important “Ready” jobs (CPU bursts), the scheduler picks the one that will finish the earliest
  • SJF is optimal among jobs available immediately
  • However being non-pre-emptive, SJF does not deal well with jobs arriving subsequently
    o Basically the big order doesn’t get prepared because small ones keep coming
20
Q

Round Robin RR algorithm

  • for how long does a process run?
  • what happens to a process after it ran for that time?
  • how are the processes moved?
A
Round Robin (RR)
-	Round robin algorithm is a turn-taking algorithm
  • There is a fixed-size quantum or slice
    o So the process runs for a quantum time
  • After the process has been running for this time:
    o An interrupt is sent to the running process
    o It is moved to end of the ready queue
    o Next item in ready queue moves to running
21
Q

PROCESS - address space

A

A process contains:
- Address space
o Code and data for running the program

22
Q

PROCESS - CPU state

A
  • CPU state
    o Program counter(PC) pointing to the next instruction
    o Stack pointer
    o General purpose register values
23
Q

PROCESS - set of resources

A
  • Set of resources
    o files
    o network connections
    o other hardware resources
  • A program is a piece of code, while a process is a dynamic instance of a program