Topic #3: Threads and Processes Flashcards

1
Q

It is an abstraction of a running program, an activity of some kind

A

Process

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

It is a series of instructions for a computer to perform that may be stored on a disk

A

Program

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

It is the rapid switching back and forth of pseudo parallel sequential processes

A

Multiprogramming

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

Events which cause Processes Creation

A
  • System Initialization
  • Execution of a process creation system call by a running process
  • 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
5
Q

Events which cause Termination

A

Normal Exit (Voluntary)
Error Exit (Voluntary)
Fatal Error (Involuntary)
Killed by another process (Involuntary)

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

Three States a process may be in

A

Running
Ready
Blocked

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

A state that a process can be in that refer to actually using the CPU at that instant

A

Running

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

A state that a process can be in that refers to a runnable or a temporarily stopped process to let others run

A

Ready

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

A state that a process can be in wherein it is unable to run until some external event happpens

A

Blocked

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

It is where information that must be saved when the process is switched from running to ready or blocked state so that it can be restarted later

A

Process table

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

Other name for Processs Table

A

Process Control Blocks

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

How many entries are there per process

A

One entry per process

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

It contains the address of the interrupt service procedure

A

Interrupt Vector

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

It is a signal emitted by a device attached to a computerr or a from a program that requires the OS to stop and figure out what to do next

A

Interrupt

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

These are sometimes referred to as lightweight processes

A

Threads

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

It is the situation that allows multiple threads to run within the same process

A

Multithreading

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

Advantages of Threads

A
  • threads are more responsive as it executes an output and can be immediately returned
  • context switch time between threads is lower
  • multiple threads can be scheduled on multiple processor
  • resources can be shared among all threads in a process
  • communication between threads is eeasier as they share an address space
  • multiple threads = multiple jobs = multiple completion = increased throughput
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

It is the thread package defined by the IEEE to make it possible to write protable threaded programs

A

Pthreads

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

It is a thread call that creates a new thread

A

Pthread_create

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

It is a thread call that terminates the calling thread

A

Pthread_exit

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

It is a thread call that waits for a specific thread to exit

A

Pthread_join

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

It is a thread call that releases the CPU to let another thread run

A

Pthread_yield

23
Q

It is a thread call that creates and initializes a thread’s attribute structure

A

Pthread_attr_init

24
Q

It is a thread call that removes a thread’s attribute structure

A

Pthread_attr_destroy

25
All Pthreads have certain properties
- an identifier - a set of registers - a set of attributes
26
Main places to implement threads
- user space - the kernel
27
Implementing Threads in User Space
- kernel knows nothing about them; it is managing single-threaded proccesses - each process needs its own thread table - implemented by a library
28
Advantages of Implementing Threads in User Space
- Can be implemented in an OS that does not support threads - customized scheduling algorithm for each process - it scales better
29
Disadvantages of Implementing Threads in User Space
- problem of howw blocking system calls are implemented - problem of page faults - one thread can only use the CPU - programmers want theads where threads are blocked often
30
Implementing Threads in a Kernel
- No run-time system is needed - no thread table for each process; one thread table for the entire system - information about the threads is now ketp in the kernel - no need for nonblocking system calls
31
Pros and Cons of Nonblocking system calls
- a system call is susbtantial and requires more overhead but has issues with signals
32
Hybrid Implementation of Threads
- kernel is aware of only kernel-level threads and schedules those - some of the kernel threads may have user-level threads multiplexed on top - user level threads are created, destroyed, scheduled like other user-level threads even if OS cant multihread - each kernel-level thread takes turns using user-level threads in the kernel
33
IPC
Inter-process Communication
34
Mechanisms for IPC
- Atomic Read/Write - Locks - Semaphores - Monitors - Message Passing
35
Need to communicate with other processes
- to pass info form process to process - to enable proper sequencing when dependencies are present - to ensure that no two process are the in the critical region at the same time
36
Race Conditions
Two or more processes are reading and writing shared data
37
Conditions in order to avoid race conditions
- Mutual Exclusion: No two processes may be simultaneously in the critical regions - No Assumption: no assumptions may be made about speeds or the number of CPUs - Progress: no process running outside its critical region may be blocked - No Starvation: no progress should have to Wait forever to enter the critical region
38
it is a condition required for the avoidance of a racce condition wherein no two proccesses may be simultaneously be inside their critical regions
Mutual Exclusion
39
it is a condition required for the avoidance of a racce condition wherein no assumptions may be made about the speeds or the number of CPUs
No assumptions
40
it is a condition required for the avoidance of a racce condition wherein no process running outside its critical region may block other processes
Progress
41
it is a condition required for the avoidance of a racce condition wherein no process should have to wait forever to enter its critical region
No Starvation
42
It is the part of the program where shared variables are accessed
Critical Region
43
Disabling Interrupts
Each process disables all interrupts just after entering the critical region and re-enable them before leaving
44
It is a single shared variable where the process sets it to 1 and enters the critical region, if it is 1 the process has to wait for it to become 0
Lock Variables
45
Classsical IPC Problem
- Producer-Consumer Problem - Dining Philosopher Problem - Reader Writers Problem
46
Explain the Dining Philosophers Problem
It models processes competing for exclusive access to limited resources
46
Explain the Producer-Consumer Problem
- It models acess to a bounded buffer - Producers wont try to add data into the buffer if its full and consumers wont try to remove data if buffer is empty
47
Explain the Readers-Writers Problem
- Models access to a database - two readers can read at once: a writer should not wait longer than needed
48
What are the units of execution
Processes
49
How are the units of execution represented
Process Control Blocks
50
How is work scheduled in the CPU
- Process States - Process Queues - Context Switches
51
How does a process move from one state to another
- Scheduling - I/O - Creation - Termination
52
How are processes created
- CreateProccess (Windows) - Fork/exec (Unix)
53
Comparea and Contrast Kernel-Level Threads ot User-level threads
Kernel-level threads are better but requires significant overhead; User-level threads are better but are not well integrated in the OS