Section 1

Preview this deck

Please briefly discuss the advantages and disadvantages of implementing threads in user space and kernel space, respectively.

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 14, 2020

Cards (12)

Section 1

(12 cards)

Please briefly discuss the advantages and disadvantages of implementing threads in user space and kernel space, respectively.

Front

As discussed in the class, the advantages and disadvantages of implementing threads in user space are below: Advantages + Fast thread switching than trapping to the kernel 3 + Each process can have its own customized scheduling algorithm Disadvantages - Blocking system calls from any thread will block the entire process - Page faults (requiring disk accesses) from any thread block the entire process - No clock interrupts (no round-robin scheduling), need voluntary yield - Limited performance gain as system calls block threads The advantages and disadvantages of implementing threads in kernel are: Advantages + When a thread blocks, the kernel can schedule another thread from the same process (if ready) or a thread from a different process to run, thus not blocking the process + No new non-blocking system calls required (including dealing with page faults) + Performance gain for mixed computing and I/O, as threads provide higher degree of parallelism, even within a process Disadvantages - Higher cost of creating/destroying threads as these require system calls, which is more costly than creating/destroying a user space thread

Back

What is a process in an operating system? What is a thread in an operating system?

Front

A process is a running program (binary, executable file) associated with necessary resources (e.g. address space, registers, open files, signals, etc.) to support running the program. (Process also provides an abstraction to support multiprogramming.) A thread is also called a lightweight process. Each thread can fetch and execute instructions independently (represent an independent control stream), but share address space and many other resources, such as open files, signals, accounting info, etc., among each other, which is different from the process model.

Back

briefly discuss these 11 steps involved in making the system call read(fd, buffer, nbytes).

Front

Steps 1-3: Push parameters nbytes, &buffer, fd Step 4: Call the library procedure read Step 5: The library procedure put a code for read in register Step 6: Call trap instruction, trap to the kernel Step 7: The kernel locates and dispatches the system call handler via a table of pointers to system call handlers indexed on system call number Step 8: The system call handler runs Step 9: Returns to the user-space library procedure Step 10: The library procedure returns to the user program Step 11: The SP is incremented (pop up, as stack grows downwards) to clean up the stack

Back

What is a trap instruction? Explain its use in operating systems.

Front

A trap instruction switches the execution mode of a CPU from the user mode to the kernel mode. This instruction allows a user program to invoke functions in the operating system kernel

Back

What is multiprogramming

Front

Multiprogramming is running multiple processes simultaneously; in other words, it is the rapid switching of the CPU between multiple processes

Back

2 Main functions of an operating system?

Front

1)Provide app programmers a clean abstract set of resources. 2) managing hardware resources as a resources manager

Back

In Fig. 2-8, a multithreaded Web server is shown. If the only way to read from a file is the normal blocking read system call, do you think user-level threads or kernellevel threads are being used for the Web server? Why?

Front

If the only way to read from a file is the normal blocking read system call, a worker thread will block when it has to read a Web page from the disk. If user-level threads are being used, this action will block the entire process, destroying the value of multithreading. Thus, it is essential that kernel threads are used to permit some threads to block without affecting the others.

Back

Please list two disadvantages of a monolithic operating system structure and two advantages of a microkernel operating system structure

Front

A monolithic OS structure can have issues/disadvantages like: 1) difficult to manage as it is essentially a collection of procedures linked together and visible to each other; and 2) vulnerable in terms of protection/security. A microkernel OS structure can have advantages like: 1) less buggy as the kernel is minimized; 2) 3 less catastrophic even if an error/failure happens; and 3) high reliability and better security protection.

Back

In the example given in Fig. 1-17, the library procedure is called read and the system call itself is also called read. Is it essential that both of these have the same name? If not, which one is more important?

Front

It is more important for the library procedure to have that name. When the library procedure read traps to the kernel, it puts the code of the system call in a register. This code is used to index into a table. In other words, this code is critical to identify the system call being invoked, not the naming of the system call. On the other hand, the name of the library procedure is very important, since that is what appears in the program

Back

In a system with threads, is there one stack per thread or one stack per process when user-level threads are used? What about when kernel-level threads are used? Please explain.

Front

Each thread calls procedures on its own, so it must have its own stack for the local variables, return addresses, and so on. This is equally true for user-level threads as for kernel-level threads

Back

What are Program Counter (PC), Stack Pointer (SP), and Program Status Word (PSW) registers?

Front

Program Counter register is a register containing the memory address of the next instruction to be fetched, i.e. a register containing the instruction address; (2) Stack Pointer register, or SP register, is a register containing the address of the top of the current stack in memory; (3) Program Status Word register, or PSW register, is a register containing the condition code bits, e.g. CPU priority, mode (user/kernel), which is needed in system calls and I/O.

Back

What is the purpose of a system call in an operating system?

Front

A system call allows a user process to access and execute operating system functions inside the kernel. User programs use system calls to invoke operating system services.

Back