CSC 246 - Midterm

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Consider the system call used to create an anonymous pipe. What parameters does this system call take? a. An array, with room for two file descriptors. b. A string containing a unique name. c. It doesn't take any parameters. d. A unique integer and one or more flags.

A

What normally causes some process, P, to switch from the running state to the waiting state? a. Process P makes a system call asking for I/O. b. Some other process starts running (i.e., enters the new state). c. Some other process terminates (i.e., enters the terminated state). d. A I/O operation previously requested by P is completed. e. Some other process sends a signal to P.

A

When does the operating system save copies of all the CPU registers for a process? a. During a context switch. b. Whenever a process transitions from the waiting state to the ready state. c. Whenever a process terminates. d. Whenever a new process is started. e. Whenever the system is powered down.

A

When using POSIX semaphores, what's the difference between sem_init() and sem_open()? a. sem_init() is for making semaphores that will be used between threads in the same process, while sem_open() is for semaphores that will be used between processes. b. You have to call sem_open() first, to make a semaphore, then you have to call sem_init() on that semaphore before you can use it. c. sem_init() is used for making new semaphores, while sem_open() is for accessing semaphores that have already been created. d. sem_init() works with a pointer to a semaphore, while sem_open() expects a copy of a whole semaphore as a parameter.

A

Which of these best describes a difference between user-level and kernel-level threads running inside the same process? Pick the best answer. a. Kernel-level threads require a system call to create a new thread, but user-level threads can make a new thread with a subroutine call. b. User-level threads each have a different heap and data section, but kernel-level threads can share these. c. The maximum number of kernel-level threads is limited to the number of CPU cores, but a process can have any number of user-level threads. d. User-level threads can share stack space, but kernel-level threads each need their own stack.

A

Which are the three different ways the CPU can go from user mode to kernel mode? a. software error b. system call c. return-from-trap instruction d. dual-mode operation e.hardware interrupt f. privileged instruction

A, B, E

In the bounded buffer producer consumer problem, when does a thread block? a. when it produced an item and the buffer is full. b. when it produced an item and the buffer is empty. c. when it's trying to consume an item and the buffer is empty. d. when it's trying to consume an item and the buffer is full.

A, C

What are shared by threads? Select two answers that apply. a. Heap b. Program Counter c. Stack d. Opened files

A, D

For load balancing, the Linux CPU scheduler will occasionally need to move processes among the CPU cores. Otherwise, it tries to always run every CPU burst of a given process on the same CPU core. This is an effort to provide a. Asymmetric multiprocessing b. Soft processor affinity c. Hard processor affinity d. Symmetric multiprocessing

B

How is a trap different from a hardware interrupt? Choose the best answer. a. When a trap occurs, the CPU jumps to a handler in the user program, rather than in the OS. b. A trap is caused by an instruction in the program that's running. c. A trap is caused by the operating system. d. After the handler finishes executing, a trap never returns to the previously running program.

B

The Process Control Block does NOT contain: a. process ID. b. open file content. c. process state. d. program counter value.

B

When using POSIX threads, a thread's start routine takes just one parameter. How do you pass in a value for this parameter? a. You can't pass in a value for this parameter. The operating system uses this parameter to give the thread a pointer to its own thread handle. b. The last parameter to pthread_create() is passed in to the start routine. c. When you call the start routine from main(), you can provide a value for this parameter. d. You can't provide a value for this parameter. It's automatically set to null for the first thread that's created. For each subsequent thread, it's a pointer to a handle for the most recently created thread.

B

Which of the following is correct regarding operating system? a. Operating system is an interface between the hardware and application programs. b. All of the mentioned. c. Operating system is a system service provider to the application programs. d. Operating system is a collection of programs that manages hardware resources.

B

Which of these system calls causes a process to run a different program? a. open() b. execl() c. fork() d. _exit() e. wait()

B

Which of the following system calls gets the operating system to put a shared memory segment in a process' address space? a. shmctl() b. shmdt() c. shmat() d. shmget()

C

A process has the following four memory regions. Which of these will typically be read-only? a. The heap b. The stack c. The data section d. The text section

D

After creating an anonymous pipe, how can a process send a message via the pipe? a. The process can store any integer value in the file descriptor for the writing end of the pipe. b. There's a send() system call for sending messages. c. It can use the read() system call. d. It can use the write() system call.

D

If you're using POSIX threads, what happens when a thread returns from its start routine? a. That thread returns back to main() and resumes executing there. b. That thread goes back to the top of its start routine and continues executing from there. c. Threads can't return from their start routine. Instead, they have to call pthread_join() to wait until other threads are finished. d. That thread terminates.

D

To directly access the services of the operating system, the interface is provided by the __________. a. Assembly instructions b. Library c. CPU d. System calls

D

A context switch happens on every timer interrupt. Select one: True False

False

Between the two types of communications models, POSIX anonymous pipe is an example of message passing but not shared memory. Select one: True False

True


Set pelajaran terkait

Chapter 12 Test Review: Chemical Bonding

View Set

Music Appreciation Chpt. 4: Baroque Period

View Set

ch. 8 elements of an organization

View Set

Theories of Personality Key Terms and Ideas Review

View Set

Chapter 9 Bio, Chapter 2, ECM, Bio Ch 18, Cell Biology Ultimate v1.1, Chapter 17 End of note questions, Chapter 11, Biology Lab Exam II, DNA Replication Questions, ch 17,18,20,22 practice questoions, Bio 1113, Ch. 6, Bio lab exam, Chapter 10 flashcar...

View Set