{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

2 Flashcards

(66 cards)

1
Q

Q: What is a process in the context of operating systems?

A

A: A process is a program in execution. OS processes run in kernel mode, while user processes run in user mode.

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

Q: What are the memory segments allocated to a process?

A

A: Text (program code), stack, heap, and data.

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

Q: What is the stack segment used for in a process?

A

A: The stack stores temporary data, such as local variables, function parameters, and return addresses. Its size is known at compile time.

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

Q: What is the heap segment used for in a process?

A

A: The heap is used for dynamically allocated memory during runtime, for data whose size may be unknown beforehand.

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

Q: What is stored in the data segment of a process?

A

A: Global variables of fixed size.

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

Q: What is a Process Control Block (PCB)?

A

A: A PCB is a data structure in the kernel containing information about a process, such as process state, process ID, program counter, CPU registers, memory management info, I/O status, scheduling info, and accounting details.

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

Q: How is a process identified in the operating system?

A

A: By a process ID (pid) and a pointer to its PCB in kernel space.

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

Q: What are the possible states of a process?

A

A:

New: The process is being created.
Ready: The process is waiting for CPU assignment.
Running: Instructions are being executed.
Waiting: The process is waiting for an event.
Terminated: The process has finished execution.

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

Q: What is process scheduling?

A

A: It involves managing the ready queue and device (I/O) queues, which are generally stored as linked lists.

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

Q: What is a context switch?

A

A: A context switch saves the state of a process when its execution is suspended and reloads the state when the process resumes.

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

Q: How are new processes created?

A

A: A parent process creates child processes, forming a tree of processes. Each new process is given a unique process ID (pid).

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

Q: What are the resource-sharing options between parent and child processes?

A

A:

Parent and children share all resources.
Children share a subset of the parent’s resources.
Parent and child share no resources.

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

Q: What are the execution options for parent and child processes?

A

A:

Parent and children execute concurrently.
Parent waits until children terminate.

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

Q: What are the address space options for a child process?

A

A:

The child is a duplicate of the parent.
The child has a new program loaded into its address space.

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

Q: What is the starting point for process creation?

A

A: An already running process, typically initiated through a login procedure.

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

Q: What happens when a process needs to wait for an event?

A

A: It transitions to the waiting state until the event occurs.

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

Q: What is stored in the program counter of a PCB?

A

A: The address of the next instruction to be executed.

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

Q: Why are queues used in process scheduling?

A

A: To manage processes waiting for CPU or I/O resources efficiently, often implemented as linked lists.

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

Q: What happens when a process consumes its allotted CPU time?

A

A: It is preempted, and its context is saved for later resumption.

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

Q: What is the Portable Operating System Interface (POSIX)?

A

A: POSIX is an IEEE standard API that defines system calls and interfaces to improve the portability of applications across operating systems.

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

Q: Is POSIX an operating system?

A

A: No, POSIX is not an OS. It is a standard that operating systems can implement to reduce portability effort for applications.

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

Q: What does a system supporting POSIX provide?

A

A: A host language and compiler, programming interface definition files, programming interface implementation (binary or code), and a run-time system.

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

Q: What are the key system calls in the POSIX 1003.1 API for processes?

A

A: fork(), exec(), exit(), and wait().

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

Q: What does the exec() system call do?

A

A: It replaces the process memory space with a new program, effectively running a different program in the same process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q: What does the wait() system call do?
A: It makes the parent process wait until the execution of its child process is finished.
26
Q: What is the role of exit() in POSIX processes?
A: The exit() system call terminates a process and returns an exit status to the parent.
27
Q: How are parent-child relationships managed in POSIX-compliant operating systems?
A: Parent-child relationships are recorded, and unique process identifiers (pids) are assigned to each process.
28
Q: What happens to the child process in memory after a fork()?
A: The child process receives a duplicate of the parent’s memory space.
29
Q: Why is the exec() system call commonly used after a fork()?
A: It allows the child process to load and execute a different program than the parent process.
30
Q: What is the purpose of unique process identifiers (pids) in POSIX systems?
A: PIDs uniquely identify processes in the system, ensuring proper tracking and management.
31
Q: What is the primary goal of the POSIX standard?
A: To reduce portability effort for applications across different operating systems.
32
Q: Why do cooperating processes need interprocess communication (IPC)?
A: To exchange data and coordinate actions, especially when processes work on shared tasks.
33
Q: What are the two types of IPC communication models?
A: No shared address space: Useful for exchanging small amounts of data. Shared address space: Faster but more difficult to implement due to interference.
34
Q: How does shared memory work between processes?
A: A memory segment is reserved in kernel memory and added to the space addressable in user mode, allowing other processes to access it without kernel involvement for subsequent reads or writes.
35
Q: What is the major issue with shared memory?
A: Interference: Actions of one process can disturb the assumptions or state knowledge of another process.
36
Q: What are the key features of a process?
A: Unit of work. Defines memory space. Owns resources. Has at least one associated thread of execution.
37
Q: What are the key features of a thread?
A: Unit of concurrency and scheduling. Operates within the process’s address space. Has its own execution state (CPU registers, stack, etc.).
38
Q: Why is process parallelism more expensive than multithreading?
A: Shared memory allocation overhead: Requires OS involvement. Creation overhead: Creating processes is more expensive than creating threads. Process switching overhead: Requires mode and context switching, which is costly.
39
Q: What is multithreading?
A: A programming structure where multiple threads operate concurrently within the same process, sharing its address space and resources.
40
Q: What is the advantage of structuring programs by threads instead of busy-waiting?
A: Threads eliminate the inefficiency of busy-waiting by allowing each thread to handle a specific task or input source concurrently.
41
Q: What are the main reasons to introduce threads?
A: Increase concurrency level and performance (e.g., hide latency). Enhance responsiveness. Exploit multi-core platforms. Allow natural organization (e.g., thread per event or resource).
42
Q: What is shared in multithreaded processes?
A: Threads share the process’s address space and resources.
43
Q: What are key considerations in designing concurrent programs?
A: Dividing the program into parallel activities. Load balancing. Resolving interference through synchronization.
44
Q: How does concurrency differ on single-core and multi-core systems?
A: Single-core: Threads share the CPU via time slicing. Multi-core: Threads can run in parallel on different cores.
45
Q: What are the key advantages of threads?
A: Inexpensive communication: Threads share memory, avoiding the overhead of IPC. Concurrency: Threads operate independently within the same address space. Low overhead: Thread switching is faster than process switching.
46
Q: What state does a thread maintain?
A: A thread maintains its context, which includes CPU registers and a stack image.
47
Q: What are the two types of threads in multithreading?
A: User threads (managed above the kernel via libraries) and kernel threads (supported directly by the OS).
48
Q: Name three primary thread libraries.
A: POSIX Pthreads, Win32 threads, and Java threads.
49
Q: What are the three main multithreading mapping models?
Many-to-One One-to-One Many-to-Many (+ Two-Level Model variation).
50
Q: What is the Many-to-One model?
A: Multiple user threads are mapped to a single kernel thread. Advantage: Fast thread management, no kernel involvement. Disadvantage: Only one user thread can access the kernel at a time, blocking calls affect all threads.
51
Q: What is the One-to-One model?
A: Each user thread maps to a kernel thread. Advantage: Concurrency on multiple processors. Disadvantage: Performance decreases with too many threads. Examples: Windows, Linux, Solaris 9 and later.
52
Q: What is the Many-to-Many model?
A: Multiple user threads are mapped to a limited number of kernel threads. Advantage: Combines benefits of the other two models. Disadvantage: Concurrency is limited by the number of kernel threads. Examples: Windows NT/2000 (threadfiber package), Solaris 8 and earlier.
53
Q: What is the Two-Level Model?
A: Similar to Many-to-Many but allows binding of a user thread to a kernel thread.
54
Q: What is a Lightweight Process (LWP)?
A: An intermediate structure that represents a kernel thread. It acts as a virtual processor for user threads and is scheduled by the kernel.
55
Q: How do threads achieve concurrency?
A: By dividing work among multiple threads that share resources and run in parallel on multi-core processors or interleave execution on single-core processors.
56
Q: How are threads switched in a kernel-level model?
A: The kernel handles thread switching, saving and restoring the execution state.
57
Q: How are threads switched in a user-level model?
A: The thread library handles switching. The programmer must call the library, making it "cooperative multithreading."
57
Q: What is cooperative multithreading?
A: A model where the programmer is responsible for yielding control to the thread library for thread switching.
58
Q: What is a thread pool?
A: A collection of pre-created threads waiting for tasks. Advantages: Faster than creating new threads for every task, limits the number of threads to a manageable size.
59
Q: What does the pthread_create function do?
A: It starts a new thread, allowing attributes like stack size to be set.
60
Q: What are the key functions in the Pthread interface?
A: Detach: Clean up resources when a thread terminates. Join: Wait for a thread to finish and retrieve its result. Cancel: Stop a thread's execution.
61
Q: Why is resource scheduling needed?
A: To efficiently allocate system resources (e.g., CPU, memory, I/O) to tasks since only one process or thread can use a resource at a ti
62
Q: What triggers a scheduling decision for a processor?
A: Events like a process entering the ready queue, the end of a time slice, or a process yielding the CPU.
63
Q: What triggers a scheduling decision for memory?
A: Events like a memory management call, replacement policy, or process termination.
64
Q: What are the main considerations for concurrent execution?
A: Dividing the program into parallel activities. Load balancing across threads or processors. Resolving interference with synchronization.
64