Processes & Threads Flashcards
What is the purpose of using processes in computer systems?
Processes help model and control concurrency in modern computers, allowing them to perform multiple tasks simultaneously.
How are processes organized in a multiprogramming system?
In a multiprogramming system, all the runnable software is organized into sequential processes. Each process has its own program counter, registers, and variables.
What is the difference between a process and a program?
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 are processes created in operating systems?
- 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.
What system calls are used to create processes in UNIX and Windows?
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.
What happens when a process terminates?
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 are resources shared between parent and child processes in UNIX?
the child process initially has a copy of the parent’s address space, but writable memory is not shared.
How are resources shared between parent and child processes in Windows?
the parent’s and child’s address spaces are separate from the start, and no writable memory is shared between them.
How does multiprogramming affect the performance of processes?
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.
What is the main reason for having threads in an application?
- 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 are threads different from processes in terms of resource usage?
- 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.
What are the performance benefits of using threads?
- 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 can threads be used in a word processor application?
- 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.
Why would using separate processes not be suitable for word processing tasks?
Separate processes cannot easily share a common memory and access the document being edited, unlike threads
What are the advantages and disadvantages of different server designs (single-threaded, multithreaded, nonblocking)?
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.