Processes & Threads Flashcards

1
Q

What is the purpose of using processes in computer systems?

A

Processes help model and control concurrency in modern computers, allowing them to perform multiple tasks simultaneously.

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

How are processes organized in a multiprogramming system?

A

In a multiprogramming system, all the runnable software is organized into sequential processes. Each process has its own program counter, registers, and variables.

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

What is the difference between a process and a program?

A

A process is an instance of an executing program, including the current state and resources, while a program is a set of instructions stored on disk and not actively running.

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

How are processes created in operating systems?

A
  • system initialization,
  • execution of a process-creation system call by a running process,
  • user requests to create a new process
  • or initiation of a batch job.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What system calls are used to create processes in UNIX and Windows?

A

In UNIX, the fork system call creates a new process, which is then typically followed by the execve system call to change the memory image and run a new program.

In Windows, the CreateProcess function handles both process creation and program loading.

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

What happens when a process terminates?

A

Processes can terminate voluntarily due to normal or error exit conditions. They can also terminate involuntarily due to fatal errors or being killed by another process.

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

How are resources shared between parent and child processes in UNIX?

A

the child process initially has a copy of the parent’s address space, but writable memory is not shared.

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

How are resources shared between parent and child processes in Windows?

A

the parent’s and child’s address spaces are separate from the start, and no writable memory is shared between them.

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

How does multiprogramming affect the performance of processes?

A

CPU switching between processes in a multiprogramming system, the rate at which a process performs its computation may not be uniform or reproducible. Processes should not rely on specific timing assumptions and critical real-time requirements may need special measures to ensure they are met.

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

What is the main reason for having threads in an application?

A
  • Multiple activities can run concurrently, making the programming model simpler.
  • Threads allow for parallel execution and sharing of data within the same address space.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How are threads different from processes in terms of resource usage?

A
  • Threads are lighter weight than processes and are faster to create and destroy.
  • Creating a thread is typically 10-100 times faster than creating a process.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the performance benefits of using threads?

A
  • Threads allow for overlapping of CPU-bound tasks and I/O operations, resulting in faster overall execution.
  • In systems with multiple CPUs, threads enable real parallelism, further improving performance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can threads be used in a word processor application?

A
  • Threads can be used to separate tasks like user interaction, background reformatting, and disk backups.
  • For example, one thread can interact with the user, another can handle reformatting, and a third can handle periodic disk backups.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why would using separate processes not be suitable for word processing tasks?

A

Separate processes cannot easily share a common memory and access the document being edited, unlike threads

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

What are the advantages and disadvantages of different server designs (single-threaded, multithreaded, nonblocking)?

A

Single-threaded: Simplicity but limited performance as CPU idle time increases.

Multithreaded: Higher performance through parallelism, but programming complexity increases.

Nonblocking with interrupts: Achieves high performance but requires handling of nonblocking calls and interrupts, making programming harder.

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

How can threads be used in processing large amounts of data?

A
  • Separate threads can handle input, processing, and output operations simultaneously.
  • This allows for parallel execution of input, output, and processing tasks, reducing idle time of the CPU.
17
Q

What is the classical thread model?

A
  • The classical thread model separates the concepts of resource grouping (processes) and execution (threads).
  • Processes group related resources together, while threads are entities scheduled for execution on the CPU.
  • Threads allow multiple executions to take place in the same process environment, sharing the address space and resources.
18
Q

How are threads and processes different in terms of resource sharing?

A
  • Threads share an address space and other resources within the same process.
  • Processes have their own separate address spaces and resources.