answersLogoWhite

0


Best Answer

A system call is actually a transition from user mode to kernel space to carry out a required operation..

For exp: Write() function resides in kernel space and can be accessed by a only corresponding wrapper function which was implemented in user space.. In case of Windows OS, Win32 API is the implementation to such as wrapper functions that make the actual system calls from user mode..

A kernel thread is created, scheduled and destroyed by the kernel..

Whereas a library thread (user thread) is created, scheduled and destroyed by a user level library like special threading libraries.. The kernel does know of nothing about library threads since they live in a process's boundaries and bound to its life cycle tightly..

Actually, a process is not the primary execution unit in all operating systems..

When a process is made by kernel, a new kernel thread is created and attached to that process in question..

So the library threads created in user mode by a user mode library must share the time slices given to the kernel thread by the scheduler arbitrarily during the lifetime of a process..

So a process actually has one kernel thread and all other library threads have to share the kernel thread's cycles..

Hence when a library thread makes a blocking call, all the threads within the process are blocked because as I said, actually process has only one kernel thread assigned to it and others try to make use of it..

So to prevent other threads from blocking, either you should use library threads that make use of kernel threads or you could just use the CreateThread() Win32 API system function for kernel threads but the synchronization mechanism must be provided by the programmer using events, signals, mutex, semaphore etc..

Sun, BSD Unix flavours, Windows etc follow the same threading architecture in their systems as POSIX standard..

However, a thread is a process in Linux.. That's why Linux is so powerful in server systems.. So the control is left to programmers to create a POSIX way of treading model by Clone(2) system call(s).. So address space and data etc can be shared by lightweight processes easily.. When a Linux kernel thread (child process) is crashed, it won't affect the rest of the threads belong to parent process.. This is just the opposite in other operating systems that a crashing thread will destroy all of the threads in the process..

NPTL is a great threading library that was implemented by using Linux clone(2) system call.. Linux also has another type of kernel thread only lives in kernel space that can be utilized by kernel code like modules..

User threads can't be run in parallel on the different CPUs because of this. However, they are portable..

Kernel threads can be scheduled by kernel to be run on a SMP system..

Hope this helps..

hsaq19@ TH Algan

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When a user-level thread executes a system call not only is that thread blocked but also all the threads within the process are blocked Why is that so?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is thread same as a function?

No. A process is composed of one or more threads. Threads can invoke any function of the process.


What is relationship between process and thread?

Process --1------------m-- Threads 1 process to many threads Bring up your Task Manager (if you are using a windows), Performance tap, you can see the number of process and the number of threads, usually the number of threads is a lot higher than the number of processes.


What a thread executes?

A thread can do anything a regular class does. However, the idea of having multiple threads is so that the computer can do several things simultaneously.


Threads belonging to the same process share the?

Threads belonging to the same process share the same resources and address space.


What are the advantages and disadvantages of user level threads and kernel level threads?

- USER LEVEL THREADS Aadvantages: · User-level threads can be implemented on operating system that does not support threads. · Implementing user-level threads does not require modification of operating system where everything is managed by the thread library · Simple representation which the thread is represented by a the thread ID, program counter, register, stack , all stored in user process address space · Simple management where creating new threads, switching threads and synchronization between threads can be done without intervention of the kernel · Fast and efficient where switching thread is much more inexpensive compared to a system call - Disadvantages: · There is a lack of coordination between threads and operating system kernel. A process gets one time slice no matter it has 1 thread or 10000 threads within it. It is up to the thread itself to give up the control to other threads · If one thread made a blocking system call, the entire process can be blocked in the kernel, even if other threads in the same process are in the ready state KERNEL LEVEL THREAD: - Advantages: · Because kernel has the full knowledge of all the threads, scheduler may decide to allocate more time to a process having large number of threads than process having small number of thread, where the kernel threads come useful for intense application - Disadvantages: · Kernel level threads are slow and inefficient, since kernel must manage and schedule all the threads as well as the processes. It requires a full TCB for each thread to maintain information about threads, which results in increasing of overheads and kernel complexity


What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in. Within this process the thing, which is really executed is the thread. The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application. Threads share the address space of the process that created it; processes have their own address. Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process. Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes. Threads have almost no overhead; processes have considerable overhead. New threads are easily created; new processes require duplication of the parent process. Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes. A great answer to the question can also be found here: (link moved to link section)


Which is not shared by the threads of the same process?

stack


What is a thread and how does it relate to a process?

A process is composed of one or more threads of execution. Multiple threads allow a process to perform two or more operations concurrently. This is particularly useful in machines with two or more processors as the threads can execute simultaneously. All the threads of a process run in a shared memory space; separate processes run in separate memory spaces. A process must have at least one thread, the primary thread. However, threads can spawn new threads as required. Each thread has its own call stack but shares the same data segment and virtual address space as the process.


What resources are shared by all threads of a process?

The resources that are shared by all threads of a process in Operating SystemsareMain memoryInput Output DevicesInput Output ChannelsFiles


What takes longer a context switch with user level threads or one with kernel level threads?

Kernel level threads take a longer time to context switch since OS will have to save and reload each and every TCB (Thread Control block) where as in user level no kernel intervention threads simply context switch more efficiently. But there are disadvantages such as since OS sees the user leve threads as a whole process it will not give a large portion of CPU time for execution if a thread is blocked the whole process goes to the waiting state please correct my answer if im wrong godlovesu49@hotmail.com thanks regards yo


What do you mean by overhead in process and why do threads dont have overhead?

Process has it's own address space while threads are using process's address space when process is switching from one to another it will save process data during that time no productive work will done by cpu, while threads are using process's data so it can directly switch from one thread to other that's why processes have overhead when they are switching from one to other while threads doesn't have overhead.


How process and threads relate to CPU architecture?

A process is a program in execution,it needs resources like CPU time,memory,files and i\o devices to accomplish its task. Threads are lightweight process