Quiz 2 Flashcards

1
Q

What is the difference between a program and a process?

A

A process is simply a program that is currently in execution.

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

What are the different components of a process?

A

The program code, or the text section.

Current activity including program counter, processor registers.

Stack containing temporary data - Function parameters, return addresses, local variables

Data section containing global variables

Heap containing memory dynamically allocated during run time.

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

What are the process states?

A

New: The process is being created

Running: Instructions are being executed

Waiting: The process is waiting for some event to occur

Ready: The process is waiting to be assigned to a processor

Terminated: The process has finished execution

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

What is process scheduling/scheduler?

A

Maximizes CPU use, quickly switches processes onto CPU core. Process scheduler selects among available processes for next execution on CPU core. Maintains scheduling queues of processes.

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

What are ready and wait queues?

A

Ready queue - Set of all processes residing in main memory, ready and waiting to execute

Wait queues - Set of processes waiting for an event (i.e. I/O)

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

What is a context switch?

A

When a CPU switches to another process the system must save the state of the old process and load the saved state for the new process via a context switch.

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

What is the PCB?

A

A context of a process is represented in the Program Control Block or PCB.

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

How is time related to context switching?

A

Context-switch time is overhead, the system does no useful work while switching. The more complex the OS and the PCB the longer the context switch. Some hardware provides multiple sets of registers per CPU meaning multiple contexts loaded at once.

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

What does process creation mean?

A

A parent process creates child processes, which in turn create other processes, forming a tree of processes.

Generally process identified and managed via a process identifier (pid)

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

When a parent creates a new child process what are the possibilities in terms of execution and address space for the new process.

A

Resource Sharing:

  • Parent and child share all resources
  • Children share subset of parent’s resources
  • Parent and child share no resources.

Execution options

  • Parent and child execute concurrently
  • Parent waits until children terminate.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are some unix commands associated with process creation?

A

fork() - Creates a new process
exec() - System call used after fork() to replace the process’ memory space with a new program.
exit() - Terminates a child process
wait() - Parent processes will wait for the child to terminate.

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

What does process termination mean?

A

Process executes last statement and then asks the operating system to delete it using the exit() system cal.

  • Returns status data from child to parent (via wait())
  • Process’ resources are deallocated by operating system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How does a parent terminate a child process? Why would this be done?

A

A parent may terminate the execution of children processes using the abort() system call. Some reasons for doing so:

  • The child has exceeded allocated resources
  • Task assigned to child is no longer required
  • The parent is exiting and the operating system does not allow a child to continue if its parent terminates.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is cascading termination?

A

Some operating systems do not let a child exist if its parent has terminated. Therefore when a process terminates all its children must also be terminated. Cascading termination refers to the process of all children, grandchildren etc. processes of a process being terminated.

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

What are the two types of processes within a system?

A

Independent - Process cannot affect or be affected by the execution of another process

Cooperating - Process can affect or be affected by the execution of another process

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

What are some reasons for using cooperating processes?

A
  • Information sharing
  • Computation speedup
  • Modularity
  • Convenience
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the IPC and what are the models?

A

Interprocess communication is required for cooperating processes.

Models are

  • Shared Memory
  • Message Passing
18
Q

What is the producer-consumer problem?

A

Paradigm for cooperating processes, producer process produces information that is consumed by a consumer process.

  • unbounded buffer places no practical limit on the size of the buffer
  • bounded buffer assume that there is a fixed buffer size.
19
Q

What is the shard memory model?

A

An area of memory shared among cooperating processes that wish to communicate.
The communication is under the control of the users processes not the operating system.
Major issue is to provide mechanism that will allow the user processes to synchronize their actions when they access shared memory.

20
Q

What is the message passing model?

A
  • Mechanism for cooperating processes to communicate and synchronize their actions.
  • Message system - processes communicate with each other without resorting to shared variables.
  • IPC facility provides two operations: send(message) and receive(message)
  • The message size can be either fixed of variable.
21
Q

How do two processes communicate in the message passing model?

A

The processes must establish a communication link between them and exchange messages via send/receive commands.

22
Q

What are some implementation issues of the message passing model?

A
  • How are links established?
  • Can a link be associated with more than two processes?
  • How many links can there be between every pair of communicating processes?
  • What is the capacity of a link?
  • Is the size of a message that the link can accommodate fixed or variable?
  • Is a link unidirectional or bi-directional?
23
Q

What is direct communication?

A

-Processes must name each other explicitly:
send(P, message) - Send a message to process P
receive(Q, message) - receive a message from process Q

  • Links are established automatically
  • A link is associated with exactly one pair of communicating processes
  • Between each pair there exists exactly one link
  • The link may be unidirectional but it is usually bi-directional.
24
Q

What is indirect communication?

A

Messages are directed and received from mailboxes or ports.
-Each mailbox has a unique ID processes can communicate only if they share a mailbox.

  • Link established only if processes share a common mailbox
  • A link may be associated with many processes
  • Each pair of processes may share several communication links
  • Link may be unidirectional or bi-directional
25
Q

What are so operations of indirect communication?

A

-Create a new mailbox (port)
-Send and receive messages through mailbox:
send(A, message) - Send a message to mailbox A
receive(A, message) - Receive a message from mailbox A
-Destroy a mailbox

26
Q

What is synchronization?

A

Message passing may be either blocking or non-blocking.

Blocking is considered synchronous
Blocking send - The sender is blocked until the message is received.
Blocking receive - The receiver is blocked until a message is available.

Non-blocking is considered asynchronous
Non-blocking send - The sender sends the message and continues.
Non-blocking receive - The receiver receives a valid message or a null message.

27
Q

What is a thread?

A

A thread is a line of execution within a program.

28
Q

What are some tasks that can be implemented by separate threads?

A
  • Update display
  • Fetch data
  • Spell checking
  • Answer a network request
29
Q

What’s the difference between process creation and thread creation?

A

Process creation is heavy-weight while thread creation is light-weight

30
Q

What are the benefits of multi-threaded programming?

A

Responsiveness – may allow continued execution if part of process is blocked, especially important for user interfaces

Resource Sharing – threads share resources of process, easier than shared memory or message passing

Economy – cheaper than process creation, thread switching lower overhead than context switching

Scalability – process can take advantage of multicore architectures

31
Q

What is multicore programming?

A

Multicore or multiprocessor systems putting pressure on programmers, challenges include:

  • Dividing activities
  • Balance
  • Data splitting
  • Data dependency
  • Testing and debugging
32
Q

What is the difference between parallelism and concurrency?

A

Parallelism implies a system can perform more than one task simultaneously

i.e. Having multiple cores, each executing commands at the same time

Concurrency supports more than one task making progress
Single processor / core, scheduler providing concurrency

i.e. Having one core executing commands intertwined with each other.

33
Q

What are the types of parallelism?

A

Data parallelism – distributes subsets of the same data across multiple cores, same operation on each

Task parallelism – distributing threads across cores, each thread performing unique operation

34
Q

What are user threads?

A
Management done by user-level threads library
Three primary thread libraries:
 POSIX Pthreads
 Windows threads
 Java threads
35
Q

What are kernel threads?

A
Threads supported by the Kernel
Examples – virtually all general purpose operating systems, including:
Windows 
Linux
Mac OS X
iOS
Android
36
Q

What is the many-to-one model?

A
  • Many user-level threads mapped to single kernel thread
  • One thread blocking causes all to block
  • Multiple threads may not run in parallel on multicore system because only one may be in kernel at a time.
  • Few systems currently use this model. Solaris Green Threads and GNU Portable Threads are two examples.
37
Q

What is the one-to-one model?

A
  • Each user-level thread maps to kernel thread
  • Creating a user-level thread creates a kernel thread
  • More concurrency than many-to-one
  • Number of threads per process sometimes restricted due to overhead
  • Examples
    • Windows
    • Linux
38
Q

What is the many-to-many model?

A
  • Allows many user level threads to be mapped to many kernel threads
  • Allows the operating system to create a sufficient number of kernel threads
  • Windows with the ThreadFiber package
    • Otherwise not very common
39
Q

What are thread libraries?

A

Thread library provides programmer with API for creating and managing threads

Two primary ways of implementing

  • Library entirely in user space
  • Kernel-level library supported by the OS
40
Q

What are Pthreads?

A
  • May be provided either as user-level or kernel-level
  • A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization
  • Specification, not implementation
  • API specifies behavior of the thread library, -implementation is up to development of the library
  • Common in UNIX operating systems (Linux & Mac OS X)
41
Q

What is thread-local storage?

A
  • Thread-local storage (TLS) allows each thread to have its own copy of data
  • Useful when you do not have control over the thread creation process (i.e., when using a thread pool)
  • Different from local variables
    • Local variables visible only during single function invocation
    • TLS visible across function invocations
  • Similar to static data
    • TLS is unique to each thread