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
Q

All Pthreads have certain properties

A
  • an identifier
  • a set of registers
  • a set of attributes
26
Q

Main places to implement threads

A
  • user space
  • the kernel
27
Q

Implementing Threads in User Space

A
  • kernel knows nothing about them; it is managing single-threaded proccesses
  • each process needs its own thread table
  • implemented by a library
28
Q

Advantages of Implementing Threads in User Space

A
  • Can be implemented in an OS that does not support threads
  • customized scheduling algorithm for each process
  • it scales better
29
Q

Disadvantages of Implementing Threads in User Space

A
  • 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
Q

Implementing Threads in a Kernel

A
  • 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
Q

Pros and Cons of Nonblocking system calls

A
  • a system call is susbtantial and requires more overhead but has issues with signals
32
Q

Hybrid Implementation of Threads

A
  • 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
Q

IPC

A

Inter-process Communication

34
Q

Mechanisms for IPC

A
  • Atomic Read/Write
  • Locks
  • Semaphores
  • Monitors
  • Message Passing
35
Q

Need to communicate with other processes

A
  • 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
Q

Race Conditions

A

Two or more processes are reading and writing shared data

37
Q

Conditions in order to avoid race conditions

A
  • 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
Q

it is a condition required for the avoidance of a racce condition wherein no two proccesses may be simultaneously be inside their critical regions

A

Mutual Exclusion

39
Q

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

A

No assumptions

40
Q

it is a condition required for the avoidance of a racce condition wherein no process running outside its critical region may block other processes

A

Progress

41
Q

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

A

No Starvation

42
Q

It is the part of the program where shared variables are accessed

A

Critical Region

43
Q

Disabling Interrupts

A

Each process disables all interrupts just after entering the critical region and re-enable them before leaving

44
Q

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

A

Lock Variables

45
Q

Classsical IPC Problem

A
  • Producer-Consumer Problem
  • Dining Philosopher Problem
  • Reader Writers Problem
46
Q

Explain the Dining Philosophers Problem

A

It models processes competing for exclusive access to limited resources

46
Q

Explain the Producer-Consumer Problem

A
  • 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
Q

Explain the Readers-Writers Problem

A
  • Models access to a database
  • two readers can read at once: a writer should not wait longer than needed
48
Q

What are the units of execution

A

Processes

49
Q

How are the units of execution represented

A

Process Control Blocks

50
Q

How is work scheduled in the CPU

A
  • Process States
  • Process Queues
  • Context Switches
51
Q

How does a process move from one state to another

A
  • Scheduling
  • I/O
  • Creation
  • Termination
52
Q

How are processes created

A
  • CreateProccess (Windows)
  • Fork/exec (Unix)
53
Q

Comparea and Contrast Kernel-Level Threads ot User-level threads

A

Kernel-level threads are better but requires significant overhead; User-level threads are better but are not well integrated in the OS