0

Assume a multiprocessor architecture with an OS which may or may not support kernel-level threads

Correct me where I go wrong:

  • If a thread library is implemented entirely in user space, then the management of threads is done in user space (creation, thread tables, stack info, ect).
  • Thus, even though a process may have multiple user threads, the kernel only sees 1, single-kernel-threaded process.
  • Thus, the kernel schedular assigns CPU usage time to the process as a whole; the user-space thread library is responsible for time-slicing this CPU time amongst it's user threads.
  • (corollary 1) process A with 20 user-threads will get same priority as process B with 1 user-thread, and so the threads in process A get approximately 1/20th CPU time as thread in process B
  • (corollary 2) user threads within the same process will never be hyper-threaded (i.e. 2 threads executing on separate CPU's at the same time)
0

1 Answer 1

1

Your first three assumptions are correct.

Corollary 1 depends on the OS scheduler. Scheduling can be based on threads only, not processes so there is no inherent guarantee that processes with different thread counts get the same total time.

Many user-space schedulers go a hybrid route and schedule m user space threads to n OS threads (with m >> n), thus avoiding some of the overheads of OS thread creation. There is no way of magically achieving concurrency without resorting to OS mechanism to bootstrap it.

Sign up to request clarification or add additional context in comments.

5 Comments

How could scheduling (kernel mode) possibly work with concepts (threads) that exist only in user space? I think his first assumption is wrong.
Also, wouldn't the existance of a hybrid mode run counter to the first assumption, that the kernel is unaware of more than 1 thread in each process?
It could obviously be only cooperative multitasking, where threads regularly poll the scheduler and relinquish voluntarily. Other than that, there is nothing about threads that could not be done in user space.
@AlexanderGessler I'm pretty sure I get what your'e getting at. I think the confusion here is in my initial assumption "OS which may or may not support kernel-level threads", in which Mooing Duck is talking in context of the latter, and Alexander is talking about the former (in a m->1 mapping). Yes?
Yes, I think so. My last remark assumes presence of real OS threads. However, user space cooperative scheduling does work without them, and your assumptions should hold as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.