Skip to content
Advertisement

Who creates the Threads? Programmer, OS, Compiler OR Programming Language?

who is the first and main creator of threads? if a programming language does not support threads, can we run multithreading on it? if an OS does not support threads, can we run multithreading on it?

Advertisement

Answer

Lets look at definations: Kernel-Level and User-Level threads; cs.iit.edu

User-Level Threads

Kernel-Level threads make concurrency much cheaper than process because, much less state to allocate and initialize. However, for fine-grained concurrency, kernel-level threads still suffer from too much overhead. Thread operations still require system calls. Ideally, we require thread operations to be as fast as a procedure call. Kernel-Level threads have to be general to support the needs of all programmers, languages, runtimes, etc. For such fine grained concurrency we need still “cheaper” threads.

To make threads cheap and fast, they need to be implemented at user level. User-Level threads are managed entirely by the run-time system (user-level library).The kernel knows nothing about user-level threads and manages them as if they were single-threaded processes.User-Level threads are small and fast, each thread is represented by a PC,register,stack, and small thread control block. Creating a new thread, switiching between threads, and synchronizing threads are done via procedure call. i.e no kernel involvement. User-Level threads are hundred times faster than Kernel-Level threads.

An advantage of user-level threads is:

The most obvious advantage of this technique is that a user-level threads package can be implemented on an Operating System that does not support threads.

So if programming language supports multithreading, programmer can make thread on even run it on single-thread OS.

Advertisement