Processes and Threads Flashcards

1
Q

the process model

A

Allows the OS to simplify:
- Resource allocation
- Resource accounting
- Resource limiting
OS maintains information on the resources and the internal state of every single process in the system

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

processes in the process model

A
  • single process counter
  • each process in unique location
  • CPU switches back and forth from process to process
  • Each process has own flow of control (own logical program counter)
  • Each time we switch processes, we save the program counter of first process and restore the program counter of the
    second
  • all processes make progress, but only one is active at any given time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

concurrent processes

A
  • The CPU can be allocated in turns to different processes
  • OS normally offers no timing or ordering guarantees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

process hierarchies

A
  • 1 init process
  • parent can create many child processes
  • tree structure with process groups
  • child can have some or all resources from the parent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

parent -> child (address space)

A
  1. the child is a duplicate of the parent ⇒ it has the same data as the parent
  2. the child has a new program loaded into it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Four principal events that cause processes to be created

A
  1. System initialisation
  2. Execution of a process creation system call by a running process
  3. A user request to create a new process
  4. Initiation of a batch job
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

process termination

A

all the resources are deallocated after termination

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

a parent may terminate its child because

A
  • the child has exceeded its usage of the resources it has allocated
    • parent needs to know the state of the children → uses some mechanism
  • the task is no longer required
  • the parent is terminated itself (in some os)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

typical conditions which terminate a process:

A
  1. Normal exit (voluntary)
  2. Error exit (voluntary)
  3. Fatal error (involuntary)
  4. Killed by another process (involuntary)
    • only parent can kill the child process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

information associated with a process

A

ID (PID), User (UID), Group (GID)
memory address space
hardware registers (e.g. pc)
open files
signals

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

Where is information associated with a process stored?

A

in the operating system’s Process Table

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

PCB

A

process control block, consist of:
- process ID
- process state
- process number
- program counter
- registers (CPU registers)
- CPU scheduling information
- memory limits - memory management information
- list of open file
- accounting information
- I/O information

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

process states

A
  1. Running (actually using the CPU at that instant)
  2. Ready (runnable; temporarily stopped to let another
    process run)
  3. Blocked (unable to run until some external event
    happens)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

process blocks for input

A

running -> blocked

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

scheduler picks another process

A

running -> ready

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

scheduler picks this process

A

ready -> running

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

input becomes available

A

blocked -> running

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

Which layer handles interrupts and scheduling

A

the lowest layer of a process-structured operating system

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

scheduling queues

A
  • job queue: all processes in the system
  • ready queue: processes in the main memory and waiting for the CPU

job -> ready ->CPU

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

context switches

A

state save
state restore

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

Why is context switch time pure overhead?

A

because the system does no useful work while switching

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

Interrupt vector

A
  • Associated with each I/O device and interrupt line
  • Part of the interrupt descriptor table (IDT)
  • Contains the start address of an OS-provided internal procedure (interrupt handler)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Who continues process execution after interrupts?

A

interrupt handler

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

interrupt types

A

sw, hw, device (async), exceptions

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

what the lowest level of the operating system does when an interrupt occurs

A
  1. Hardware stacks program counter, etc.
  2. Hardware loads new program counter from interrupt vector.
  3. Assembly language procedure saves registers.
  4. Assembly language procedure sets up new stack.
  5. C interrupt service runs (typically reads and buffers input).
  6. Scheduler decides which process is to run next.
  7. C procedure returns to the assembly code.
  8. Assembly language procedure starts up new current process.
26
Q

Every time an interrupt occurs, who gets control acts as a mediator?

A

the scheduler

27
Q

thread

A

unit of execution within a process

28
Q

threading +

A

+ allows space and time efficient parallelism
+ allows simple communication and synchronisation
+ responsiveness
+ resource sharing
+ economy
+ multiprocessor utilisation

29
Q

dispatcher and worker thread

A

dispatcher: process incoming requests
working: handle the requests

30
Q

threads
single-threaded process
finite-state machine / event driven process

A

parallelism, blocking syscalls
no parallelism, blocking syscalls
parallelism nonblocking syscalls, interrupts

31
Q

Blocking syscalls

A

pause execution until completion, causing the process to wait

32
Q

Nonblocking syscalls

A

return immediately, allowing the process to continue executing even if the requested operation isn’t ready yet

33
Q

user threads

A

managed without kernel support

34
Q

kernel threads

A

managed directly by the kernel

35
Q

thread model many to one

A

one is blocked → all blocked
can access the kernel one at a time; no space for utilisation

36
Q

thread model one to one

A

costly: every user needs to create a kernel thread, heavy on the system

37
Q

thread model many to many

A

multiple user-level threads to be multiplexed over multiple kernel-level threads

38
Q

threads in a process

A
  • threads reside in the same address space of a single process ⇒ all threads can access the same memory (fast access)
  • All information exchange is via data shared between the threads
  • Threads synchronise via simple primitives
  • Each thread has its own stack, hardware registers, and state
  • Thread table/switch: a lighter process table/switch
  • Each thread may call any OS-supported system call on behalf of the process to which it belongs
39
Q

per process items

A
  1. address space
  2. global variables
  3. open files
  4. child processes
  5. pending alarms
  6. signals and signal handlers
  7. accounting information
40
Q

per thread items

A
  • ID
  • program counter
  • registers
  • stack
  • state
41
Q

user-level thread package

A

kernel has no knowledge of it → can’t go to another thread

42
Q

a thread package managed by the kernel

A

kernel maintains the threads, if a thread blocks a process the kernel can schedule it

43
Q

user threads +/-

A

+ thread switching time (no mode switch)
+ scalability, customisable

  • transparency
  • parellelism
44
Q

event driven servers

A

Implement server as finite-state machine that responds to events using
asynchronous system calls

45
Q

When to schedule?

A
  • Process exits
  • Process blocks on I/O, Semaphore, etc.
  • When a new process is created
  • When an interrupt occurs:
    ○ I/O, clock, syscall, etc.
46
Q

preemptive scheduling

A

“kick-out” running process no matter what

47
Q

non-preemptive scheduling

A

keep the process running until it leaves the CPU

48
Q

Categories of Scheduling Algorithms

A

batch
interactive
real time

49
Q

scheduling algorithm goals

A

fairness: giving each process a fair share of the CPU
policy enforcement: seeing that stated policy is carried out
balance: keeping all parts of the system busy

50
Q

batch systems

A

Throughput: maximise jobs per hour
Turnaround time: minimise time between submission and termination
CPU utilisation: keeping the CPU busy all the time

51
Q

interactive systems

A

response time: respond o requests quickly
proportionality: meet user expectations

52
Q

policy vs mechanism

A

Important principle
Here: we may have a scheduling algorithm, but parameters to be filled in by user (process)
For instance, to give some child processes higher priority than others

53
Q

real time systems

A

meeting deadlines: avoid losing data
predictability: avoid quality degradation in multimedia systems
timing plays an essential role
soft real time vs. hard real time
periodic and aperiodic tasks
static or dynamic schedules

54
Q

schedulable formula

A
55
Q

scheduling criteria - all systems

A
  • Fairness—giving each process a fair share of the CPU
  • Policy enforcement—seeing that stated policy is carried out
  • Balance—keeping all parts of the system busy
56
Q

scheduling criteria - batch

A
  • Throughput—maximize jobs per hour
  • Turnaround time—minimize time between submission and termination
  • CPU utilization—keep the CPU busy all the time
57
Q

scheduling criteria -interactive

A
  • Response time—respond to requests quickly
  • Proportionality—meet users’ expectations
58
Q

scheduling criteria - real-time

A
  • Meeting deadlines—avoid losing data
  • Predictability—avoid quality degradation in multimedia systems
59
Q

scheduling algorithms for batch systems

A

FCFS
Shortest job first
Shortest remaining time next

60
Q

scheduling algorithms for interactive systems

A

round-robin
priority
multiple queues
shortest process next
guaranteed scheduling
lottery scheduling
fair-share

61
Q

scheduling for real time systems

A

soft vs hard
period vs aperiodic
static or dynamic

62
Q
A