3

In my previous post, about the Linux kernel,

  • the structure task_struct represents threads i.e. light weight processes, but not processes.

  • processes are not represented by any structure, but by groups of threads sharing the same thread group id.

I was wondering how differently or similarly a typical Unix kernel (System V, FreeBSD, ...) implements processes and threads at a high level? Thanks.

6
  • There's probably someone here who knows this better than me :-), but I don't think System V itself implemented threads. Commented Jan 1, 2019 at 14:35
  • If you search for Solaris threads, I think you should be able to find information about Solaris userspace's first attempt using M:N threads, and then giving up and switching to 1:1 threads. In M:N threads, the application sees M threads but the kernel is only providing N threads. The C library is multiplexing them, scheduling when each application thread gets to run on one of the N kernel threads. According to Wikipedia "Solaris" proper is based on System V, but it is also described as merging both lines because SunOS was based on BSD (and presumably influenced Solaris). Commented Jan 1, 2019 at 14:35
  • @sourcejedi With Solaris the answer also changed over time, as hardware changed. So early threading was "green" (userspace many-to-one). As you mention, Sun also looked at a many-to-many model, and then a one-to-one model. There's an old whitepaper which goes into detail - web.archive.org/web/20090327002504/http://www.sun.com/software/… Commented Jan 2, 2019 at 0:45
  • @Tim Your assumptions are wrong. A task_struct represents both processes and threads. Commented Jan 2, 2019 at 6:22
  • If you look at the history of threads in Linux, you'll see there have been multiple implementations in the past, for instance LinixThreads, which is a precursor of the current NPTL implementation. There were also other thread libraries available on Linux, many implementing them in userspace, some of which predate the clone syscall. Commented Jan 2, 2019 at 9:45

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.