CSCE 3600 Midterm Exam 2 Review

Ace your homework & exams now with Quizwiz!

Match the following: Counting mechanism for resource allocation Semaphore Used to coordinate threads' execution Spurious Wakeup Non-deterministic events Deadlock Threads make no progress due to circular dependencies Semaphore An atomic increment and decrement operation Condition Variable

Counting mechanism for resource allocation Semaphore Used to coordinate threads' execution Condition Variable Non-deterministic events Spurious Wakeup Threads make no progress due to circular dependencies Deadlock An atomic increment and decrement operation Semaphore

If one thread of a process is holding the lock on a mutex, and another thread of the same process attempts to lock it, the whole process is blocked.

False

True or False: A "strong" semaphore is one that always achieves mutual exclusion. True

False

True or False: A process in the "blocked" state is currently executing on the CPU.

False

True or False: Process switching / context switching occurs only in user mode.

False

True or False: The exec() system call closes all file descriptors unless specified otherwise.

False

True or False: The maximum nice value that a process can have is 30.

False

True or False: wait() function or system call can be used to wait on at most one child.

False

Match the following: Child PID A. swapper / sched process PID 0 B. init process Zombie C. Spawned by fork() PID 1 D. Waiting to be collected by parent

PID 0 A. swapper / sched process PID 1 B. init process Child PID C. Spawned by fork() Zombie D. Waiting to be collected by parent

Match the following: PID 1 swapper process ^C background/init process PID 0 cat /proc/sys/kernel/pid_max 4194304 kill -2

PID 0 swapper process PID 1 background/init process 4194304 cat /proc/sys/kernel/pid_max ^C kill -2

True or False: A condition variable must be used in conjunction with a mutex lock.

True

True or False: A special zombie process state represents terminated processes.

True

True or False: Each process in memory has a separate PCB entry stored in a PCB table.

True

True or False: In Linux, all I/O devices are represented as files

True

True or False: In multi-threaded programs, each thread within the same process shares the same memory space and file descriptors.

True

True or False: The PCB holds the context data necessary to restore a process during a context switch.

True

True or False: The wait() system call is used by a parent process to wait for its child processes to terminate, and it retrieves the termination status of the child.

True

True or False: When a shell starts up a pipeline (e.g., when a user enters ls | less), all the commands in the pipeline go into the same process group.

True

Which are true of the semaphore operation wait()? a) A lower-level mutual exclusion mechanism is needed, to ensure that the fetching and storing of the semaphore value are done atomically. b) If the value becomes negative, the calling process is blocked c) It decrements the value of the semaphore d) It increments the value e) If the value is not positive, another process is unblocked

a) A lower-level mutual exclusion mechanism is needed, to ensure that the fetching and storing of the semaphore value are done atomically. b) If the value becomes negative, the calling process is blocked c) It decrements the value of the semaphore

What distinguishes a pipe from a socket in IPC? (Select all that apply) a) A pipe supports only unidirectional communication b) A socket supports bidirectional communication c) A pipe requires the processes to be on the same machine d) A socket can be used for network communication

a) A pipe supports only unidirectional communication b) A socket supports bidirectional communication c) A pipe requires the processes to be on the same machine d) A socket can be used for network communication

Which of the following are shared among all threads in a process? a) Address space b) Open files c) Stack d) Global variables

a) Address space b) Open files d) Global variables

Which file types are used for communication between unrelated processes? (Select all that apply) a) FIFO files b) Regular files c) Sockets d) Character special files

a) FIFO files c) Sockets

Google Chrome uses processes instead of threads for tabs to: a) Improve isolation and fault tolerance b) Use less memory c) Avoid race conditions d) Allow more concurrent threads

a) Improve isolation and fault tolerance

Spurious wakeups require that condition variable waits must be done: a) Inside a loop checking the actual condition b) Inside an if-statement c) Without a mutex d) With semaphores instead

a) Inside a loop checking the actual condition

Which scheduler controls the degree of multiprogramming? a) Long-term scheduler b) Short-term scheduler c) Swapper d) init

a) Long-term scheduler

Because thread scheduling can switch threads at any time, the programmer must: a) Program the logic so shared data access is thread-safe b) Trust the scheduler to avoid conflicts c) Avoid using shared memory d) Create a new process for each thread

a) Program the logic so shared data access is thread-safe

Which of the following actions can be performed using a file descriptor? (Select all that apply) a) Reading data from a file b) Writing data to a file c) Creating a pipe d) Managing process IDs

a) Reading data from a file b) Writing data to a file c) Creating a pipe

Which signals can be caught or handled by a custom handler? (Select all that apply) a) SIGTERM b) SIGSTOP c) SIGINT d) SIGKILL

a) SIGTERM c) SIGINT

Message passing does not involve which of the following? a) Shared variables b) Synchronization c) Communication links d) Signal handlers

a) Shared variables

Which of the following are true of the pthread_mutex_lock() operation? a) Takes a reference to a mutex as a parameter b) Intended to provide mutual exclusion c) Used to wait for a condition or event d) Takes a reference to a condition variable

a) Takes a reference to a mutex as a parameter b) Intended to provide mutual exclusion

What happens when a file descriptor is duplicated using dup2()? (Select all that apply) a) The new descriptor refers to the same file as the original b) The original descriptor is closed c) The new descriptor points to a different file d) Both descriptors refer to the same file or pipe

a) The new descriptor refers to the same file as the original d) Both descriptors refer to the same file or pipe

When a signal is delivered to a process, what happens? (Select all that apply) a) The process can choose to handle the signal, ignore it, or terminate b) The process must immediately terminate c) A signal can interrupt the normal flow of execution and trigger a handler d) Signals are always delivered in the order they are sent

a) The process can choose to handle the signal, ignore it, or terminate c) A signal can interrupt the normal flow of execution and trigger a handler

What is the primary advantage of using threads in a multi-threaded application? a) Threads allow for concurrent execution and better utilization b) Threads make the program run slower c) Threads make the code more complex and harder to maintain d) Threads utilize more memory

a) Threads allow for concurrent execution and better utilization

Which of the following statements about message buffering is true? (Select all that apply) a) Zero-capacity buffers allow the sender to send a message only when the receiver is ready b) Unbounded buffers require the sender to wait when no buffer space is available c) Bounded buffers allow the sender to continue without waiting if space is available d) Zero-capacity buffers block the sender until the receiver retrieves the message

a) Zero-capacity buffers allow the sender to send a message only when the receiver is ready d) Zero-capacity buffers block the sender until the receiver retrieves the message

Systems that allow concurrent active processes are called __________ systems. a) multiprogramming b) scheduling c) modular d) layered

a) multiprogramming

Which system call creates a pipe? a) pipe() b) open() c) dup() d) create_pipe()

a) pipe()

Which of the following is used to wake a thread blocked on a condition variable? a) pthread_cond_signal() b) pthread_cond_destroy() c) pthread_exit() d) pthread_join()

a) pthread_cond_signal()

Which of the following POSIX functions causes a thread to wait for another thread to finish? a) pthread_join() b) pthread_exit() c) pthread_create() d) pthread_kill()

a) pthread_join()

What system call sends a signal to the current process? a) raise() b) kill() c) send() d) signal()

a) raise()

Which of the following system calls sends a signal to a process? (Select all that apply) a) raise() b) kill() c) signal() d) notify()

a) raise() b) kill()

The following segment of memory contains the "executable instructions" or the "actual program code" of a process: a) text b) data c) stack d) heap

a) text

What is a signal in operating systems? a) A hardware interrupt only b) A software interrupt used to notify a process of an event c) A type of log file d) A compiled error code

b) A software interrupt used to notify a process of an event

In a system with multithreaded processes, which of the following are different for each thread? a) Virtual address space b) Execution stack c) Execution state (running, ready, etc.) d) Open files

b) Execution stack c) Execution state (running, ready, etc.)

Which of the following are types of files in Linux used for IPC? (Select all that apply) a) Regular files b) FIFO files (named pipes) c) Socket files d) Directory files

b) FIFO files (named pipes) c) Socket files

Which of the following is not a benefit of cooperating processes? a) Computation speedup b) Greater memory consumption c) Modularity d) Convenience

b) Greater memory consumption

Which statement is true about the kill() system call? (Select all that apply) a) It can only be used for terminating processes b) It can send a signal to a specific process by its PID c) It cannot send signals to process groups d) It has the same effect as the raise() function when the signal is sent to the current process

b) It can send a signal to a specific process by its PID d) It has the same effect as the raise() function when the signal is sent to the current process

What does the following code do? `void myHandler(int iSig) { printf("Signal received: %d", iSig); } signal(SIGINT, myHandler);` a) It installs a handler to terminate the process on receiving SIGINT b) It installs a custom handler that prints the signal number for SIGINT c) It will generate a segmentation fault d) It blocks all signals

b) It installs a custom handler that prints the signal number for SIGINT

Suppose P, Q, and R are co-operating processes satisfying Mutual Exclusion. If process Q is in its critical section, then: a) P executes in critical section b) R does not execute in critical section c) P does not execute in critical section d) R executes in critical section

b) R does not execute in critical section c) P does not execute in critical section

What type of thread-related error is caused by two or more threads accessing the same memory at the same time? a) Starvation b) Race condition c) Deadlock d) Signal masking

b) Race condition

Which type of file descriptor is used for network communication between processes on different machines? a) FIFO (named pipe) b) Socket c) Regular file d) Character special file

b) Socket

What does pause() do? a) Halts the process indefinitely b) Waits until a signal is caught c) Terminates the program d) Stops the OS scheduler

b) Waits until a signal is caught

Which system call replaces the current process image but retains the PID? a) fork() b) exec() c) wait() d) clone()

b) exec()

What function opens a file in standard C I/O? a) openfile() b) fopen() c) open() d) readfile()

b) fopen()

Which of the following functions takes a pointer as an argument? a) signal() b) fopen() c) raise() d) kill()

b) fopen()

Which command lists open files for a process? a) openlist -p b) lsof -p c) ps -f d) netstat -p

b) lsof -p

In a state diagram, what is the first state after a process is created? a) running b) new / created c) ready d) waiting

b) new / created

What are the two primitive operations used in message passing? a) send and kill b) send and receive d) signal and raise d) open and close

b) send and receive

Which of the following is not thread-safe by default? a) strtok_r() b) strtok() c) localtime_r() d) gmtime_r()

b) strtok()

What is the file descriptor number for stderr? a) 0 b) 1 c) 2 d) 3

c) 2

What is the default behavior when a process receives a SIGSEGV? a) The process is paused b) The process continues normally c) A core dump is generated, and the process is terminated d) A custom signal handler is automatically invoked

c) A core dump is generated, and the process is terminated

Which of the following statements is True about the exec family of functions? a) All six return the PID of the new process b) All six immediately create a new process c) All six replace the calling process's memory image d) All six require the full path of the binary

c) All six replace the calling process's memory image

What is the main difference between blocking and non-blocking message passing? a) Blocking operations never complete b) Non-blocking operations use critical sections c) Blocking waits for message delivery; non-blocking does not d) Non-blocking uses only sockets

c) Blocking waits for message delivery; non-blocking does not

What kind of file is /dev/tty2? a) Block special b) Directory c) Character special d) Regular

c) Character special

What mechanism ensures mutually exclusive access to shared data? a) Signal handler b) Pipe c) Critical section d) Semaphore

c) Critical section

What does dup2() do? a) Executes a child process b) Duplicates a pipe c) Duplicates one file descriptor to another d) Increments a process ID

c) Duplicates one file descriptor to another

The system-level context includes: a) Program counter and stack b) Code segment c) File descriptors and signals d) Function arguments

c) File descriptors and signals

Why might an OS support cooperating processes? a) To ensure each process is isolated b) To slow down computation c) For convenience, modularity, and computation speedup d) To prevent shared data access

c) For convenience, modularity, and computation speedup

Which of the following is not part of the register context? a) Program Counter b) Stack Pointer c) Global Variables d) General-purpose registers

c) Global Variables

What does the following code do? int fd[2]; pipe(fd); a) It creates a socket for inter-process communication b) It creates a pipe between the process and its parent c) It creates a pipe for data communication between two processes d) It reads from the standard input stream

c) It creates a pipe for data communication between two processes

What is a critical section used for in shared memory cooperation? a) It delays message sending b) It allows non-blocking communication c) It ensures mutually exclusive access to shared data d) It duplicates signals

c) It ensures mutually exclusive access to shared data

A process is created when a program is: a) Compiled on disk b) Saved into memory c) Loaded into memory and begins execution d) Assigned a PID by the user

c) Loaded into memory and begins execution

What does a FIFO file support in IPC? a) Real-time sockets b) Memory paging c) Named pipe communication d) Critical section protection

c) Named pipe communication

What does the system use to uniquely identify and manage a process? a) Thread ID b) PCB pointer c) PID d) Stack address

c) PID

The getpgid() function call is used to: a) Get the parent group ID of a process b) Set the group ID for a process c) Return the process group ID of the specified or calling process d) Get the parent process ID

c) Return the process group ID of the specified or calling process

Which of these signals cannot be caught or ignored by a process? a) SIGTERM b) SIGINT c) SIGKILL d) SIGUSR1

c) SIGKILL

When context switching occurs, what does the CPU Scheduler do first? a) Executes exec() b) Stores the new process's PCB c) Saves the current process's context d) Checks signal table

c) Saves the current process's context

What does the pause() function do in a C program? a) Blocks until a file is read b) Terminates the process c) Suspends the process until a signal is caught d) Sends a signal to another process

c) Suspends the process until a signal is caught

What happens to the address space when fork() is called in a process? a) The child shares the same memory and sees changes made by the parent b) The child creates an entirely new memory layout with no relation to the parent c) The child gets a copy of the parent's memory, and changes in one don't affect the other d) The parent and child merge into a single process sharing memory

c) The child gets a copy of the parent's memory, and changes in one don't affect the other

Which of the following is true about independent processes? a) They require interprocess communication mechanisms b) They can affect the execution of other processes c) They do not share data with other processes d) They always use message passing for communication

c) They do not share data with other processes

Which statement is true about cooperating processes? a) They do not communicate with each other b) They operate completely independently c) They require interprocess communication d) They can only communicate via sockets

c) They require interprocess communication

Which is true about threads vs. processes? a) Threads use more memory than processes b) Threads have separate memory spaces c) Threads are lighter-weight and share memory d) Each thread needs its own process

c) Threads are lighter-weight and share memory

Context switch overhead is due to: a) High memory usage b) Re-execution of old instructions c) Time spent saving and loading contexts d) Kernel panic

c) Time spent saving and loading contexts

Which of the following is true about thread synchronization? a )Required only for read-only operations b) Needed only in single-threaded applications c) Used to ensure threads don't interfere with each other d) Forces threads to run in parallel

c) Used to ensure threads don't interfere with each other

Which buffering strategy forces the sender to wait until the receiver retrieves the message? a) Unbounded b) Bounded c) Zero-capacity d) FIFO

c) Zero-capacity

Which process state is responsible for I/O wait? a) ready b) running c) blocked d) zombie

c) blocked

Which segment contains uninitialized global and static variables? a) heap b) text c) data d) stack

c) data

Which segment in the user-level context holds dynamically allocated memory? a) text b) data c) heap d) stack

c) heap

What system call sends a signal to a specific process ID? a) exec() b) raise() c) kill() d) notify()

c) kill()

Which of the following POSIX functions is used to create a new thread? a) pthread_exit() b) pthread_join() c) pthread_create() d) pthread_self()

c) pthread_create()

Which function installs a custom signal handler? a) install_handler() b) sigtrap() c) signal() d) setjmp()

c) signal()

When using shared memory for communication, what type of synchronization is required? a) Mutex b) Semaphore c) Barrier d) All of the above

d) All of the above

What type of IPC does pipe() create? a) Character special file b) Shared memory c) FIFO (named pipe) d) Byte stream communication between two processes

d) Byte stream communication between two processes

What does the following code do? signal(SIGINT, SIG_IGN); a) Registers a custom handler for SIGINT b) Terminates the process on SIGINT c) Restores the default behavior for SIGINT d) Ignores SIGINT signals

d) Ignores SIGINT signals

What is the primary use of execlp() over execl()? a) It returns the PID b) It creates a new process group c) It accepts environment variables d) It searches for the binary in the PATH

d) It searches for the binary in the PATH

The kernel handles the exit() system call by releasing the resources owned by the process and sending the parent process a __________ signal. a) SIGKILL b) SIGSEGV c) SIGINT d) SIGCHLD

d) SIGCHLD

One can register a handler on all these signals except __________. a) SIGINT b) SIGHUP c) SIGTERM d) SIGKILL

d) SIGKILL

What IPC mechanism enables communication across different systems? a) Pipes b) Shared memory c) Signals d) Sockets

d) Sockets

_____________are programming constructs that set up a group of parameters that identifies the process request and then executes the hardware-dependent CPU instruction switch from User Mode to Kernel Mode. a) processes b) functions c) interrupts d) system calls

d) system calls

The state where a process has finished executing but has not been collected by its parent is called: a) terminated b) finished c) exited d) zombie

d) zombie

Match the following: execp() delineates that the argument is raw command path execvp() delineates that the argument is passed as a vector exec() curiously, this does not exist execv() such commands can specify a filename (uses $PATH)

exec() delineates that the argument is raw command path execv() delineates that the argument is passed as a vector execp() curiously, this does not exist execvp() such commands can specify a filename (uses $PATH)


Related study sets

Opportunities for Career Advancement

View Set

Chapter 5: Elasticity: A measure of Responsiveness

View Set

1130 Operating Systems Concepts Final Practice

View Set

Pharmacology II Prep U Chapter 47: Lipid-Lowering Agents

View Set

Mobility - Spinal Cord Injuries - Unit 4, Sem 4

View Set

C464 Module 3: Culture and Cultural Differences

View Set

chapter 13 current liabilities and contingencies.

View Set