james king
james king

Reputation: 90

Why is the Many-to-Many threading model not used in more

The book Operating System Concepts talks about the various multithreading modules (section 4.3), it mentions that the one-to-one model is used in most operating systems; Linux, Windows, etc. However, it then talks about the Many-to-Many model and that it fixes some of the issues that are seen with the One-to-One model, but later mentions that the only largely used implementation of it is with the two-level model which is just an extension of the Many-to-Many model which was used in an older version of Solaris (9) but is now no longer used and has been replaced by the one-to-one model. My question is if the Many-to-Many model is better then why is it not used more commonly? Is it due to complexity? I can imagine there could be issues with context switching if there was not some sort of a "sticky" mapping between user and kernel-level threads?

Thanks for any help with this.

Upvotes: 0

Views: 1005

Answers (1)

mevets
mevets

Reputation: 10445

It is used; go routines in Go are precisely this, managed by the Go runtime. As kernel memory became cheaper (because memory became cheaper) and pthreads use became ubiquitous, the runtime cost of managing the two level model, and the human time cost of supporting it, spelled its demise.

Go routines are a programming model, and meant to be extremely cheap, to the degree that Go programs shouldn't be ashamed to have thousands of them. The Go runtime, very carefully keeps a virtual-cpu pool (constructed with real threads), that can adopt a go routine very quickly.

Upvotes: 2

Related Questions