System calls, Processes and Threads Flashcards

1
Q

What are the two processer modes?

A

Kernel mode and User mode

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

What mode do system calls operate in?

A

Kernel mode

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

What is meant by System Calls?

A
  • OS is trusted, user is not
  • OS has super-privileges, user does not
  • Must take measures to prevent abuse
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is meant by Function Call?

A

Caller and callee are in the same process, same user, same domain of trust

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

What are some examples of POSIX system calls?

A
  • fd: open a file for reading, writing or both
  • s: close an open file
  • n: read data from a file into a buffer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is meant by a process?

A

A program in execution, which then forms the basis of all computation (an active entity)

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

What is meant by a Process Control Block (PCB)?

A

Keeps all the information needed to keep track of a process, maintained by the OS for every process

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

What are the 3 main memory segments for a process?

A
  • Text: executable code for the process
  • Data: statically defined variables
  • Stack: return address for procedure calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is meant by Multiprogramming?

A
  • Individual processes oblivious to existence of others
  • Processor rapidly switched between processes
  • Processes suspended and restarted
  • Context switch can be expensive
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Process Model?

A
  • Multiprogramming of 4 programs
  • Conceptual model of 4 independent, sequential processes
  • Only one program active at any instant
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the 4 principal events that cause processes to be created?

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

What is meant by Fork() in POSIX system calls?

A

Fork creates a new process by cloning the parent process

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

How do Parent/Child run in parallel?

A
  • By running on different processors if on a multiprocessor system, otherwise by context switching
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is meant by Context Switching?

A

Running each process in short time slots
- Saving context of one process, restoring that of another one
- Processor alternates between executing different processes

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

What are 3 states a process may be in?

A
  • Running (using the CPU at that instance)
  • Ready (paused to let another process run)
  • Blocked (waiting for some external event to happen)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is meant by a Process Table?

A
  • Records information required to restart a suspended process
  • Timer sends periodic interrupts
  • Schedular saves state of process before starting another
17
Q

What are some advantages of processes?

A
  • Program can be written as if it had the computer itself
  • Memory protection
  • Multiprogramming achieved by the OS
18
Q

What are some disadvantages of processes?

A

Context switches are very expensive

19
Q

What are some alternatives to processes?

A

Threads, much cheaper to switch threads than processes

20
Q

What is a thread?

A

A basic unit of CPU utilisation, consisting of a program counter, a stack and a set of registers (and a thread ID)

21
Q

What is meant by the Classical Thread Model?

A

Each thread has its own stack, each thread will generally call different procedures and thus have a different execution history

22
Q

What are some advantages of threads?

A
  • Less memory to maintain thread state (mostly extra stack space)
  • Less performance overhead
  • Automatic data sharing (same address space)
23
Q

What are some disadvantages of threads?

A
  • Shared memory can be source of data races
  • Less robust compared to processes
  • Memory corruption or a crash on 1 thread corrupts entire program
24
Q

Process vs Thread

A
  • Process means a program is in execution, thread means a segment of a process
  • Process is not lightweight, a thread is
  • Process consume more resources, threads consume fewer
  • Process memory is mostly isolated, threads share memory
  • Process does not share data, threads share data with each other
25
Q

What is meant by a Race Condition?

A
  • 2 or more processes are reading or writing some shared data
  • Precise outcome depends on the exact scheduling and timing of processes
26
Q

What is meant by Mutual Exclusion?

A

Only one process can access a shared resource (e.g. memory) at the same time

27
Q

What is meant by Critical Region?

A

The part of program potentially causing a race condition

28
Q

What is Serially Re-usable resource (SRR)?

A

A resource that required mutual exclusion

29
Q

What is a critical region for Mutual exclusion?

A

No 2 processes may be simultaneously inside their critical regions

30
Q

What is a critical region for Architectural Neutrality?

A

No assumptions may be made about speeds or the number of CPUs

31
Q

What is a critical region for Progress?

A

No process running outside its critical region may block other processes

32
Q

What is a critical region for Bounded Waiting?

A

No process should have to wait forever to enter its critical region