Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Test 1: Operating Systems Why Does Threads have private Registers? Threads have

ID: 3745126 • Letter: T

Question

Test 1: Operating Systems Why Does Threads have private Registers? Threads have stacks? Why? During a Interrupt, which stack is utilized? User level or kernel level? C) . Difference between Kernel thread, kernel-level thread and a process being executed in kernel mode? 3 advantages and 3 disadvantages of memory shared and client- server for IPC? Once the information is copied from user memory to kernel memory, why does it make sense allow a kernel thread to finish handling the information? If code in the kernel needs to access user space, do you need to wait for a context-switch? before you can gain access? Explain . ·

Explanation / Answer

Threads

Despite of the fact that a thread must execute in process, the process and its associated threads are different concept. Processes are used to group resources together and threads are the entities scheduled for execution on the CPU.
A thread is a single sequence stream within in a process. Because threads have some of the properties of processes, they are sometimes called lightweight processes. In a process, threads allow multiple executions of streams. In many respect, threads are popular way to improve application through parallelism. The CPU switches rapidly back and forth among the threads giving illusion that the threads are running in parallel. Like a traditional process i.e., process with one thread, a thread can be in any of several states (Running, Blocked, Ready or Terminated). Each thread has its own stack. Since thread will generally call different procedures and thus a different execution history. This is why thread needs its own stack. An operating system that has thread facility, the basic unit of CPU utilization is a thread. A thread has or consists of a program counter (PC), a register set, and a stack space. Threads are not independent of one other like processes as a result threads shares with other threads their code section, data section, OS resources also known as task, such as open files and signals

Why Threads?

Following are some reasons why we use threads in designing operating systems.

Threads are cheap in the sense that

But this cheapness does not come free - the biggest drawback is that there is no protection between threads.

Multi-threaded applications cannot take advantage of multiprocessing.

IPC Client server

Advantage
-----------
1. Useful for exchanging small amounts of data.
2. Simple to implement in the OS.

Disadvantage
------------
1. Cumbersome b/c code is sprinkled with send/recv OPs.
2. High-Overhead: one syscall per communication operation.

IPC - Shared Memory:

Advantage
------------
1. Low-Overhead: a few syscalls initially, then none.
2. More convenient for user (b/c read/write to/from RAM - like normal).

Disadvantage
------------
1. Harder to implement in the OS.

S.N. User-Level Threads Kernel-Level Thread 1 User-level threads are faster to create and manage. Kernel-level threads are slower to create and manage. 2 Implementation is by a thread library at the user level. Operating system supports creation of Kernel threads. 3 User-level thread is generic and can run on any operating system. Kernel-level thread is specific to the operating system. 4

Multi-threaded applications cannot take advantage of multiprocessing.

Kernel routines themselves can be multithreaded.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote