uwhpsc-2016 / lectures

Notes, slides, and code from the in-class lectures.
7 stars 21 forks source link

Threads as smallest sequences? #12

Open gadamico opened 8 years ago

gadamico commented 8 years ago

The Wikipedia article on threads says: "In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system."

What does 'smallest' mean here? And if it has some normal meaning, then why wouldn't the smallest such sequence have only one instruction in it (or even zero instructions)? Is it somehow the case that, when a sequence gets sufficiently small, its execution cannot be handled by a scheduler?

quantheory commented 8 years ago

I believe that what the Wikipedia entry means is that a scheduler may be aware of a hierarchy of instruction sequences, so a thread is contained in a process, a process may be part of some group of processes defined by the scheduler.

The thread is the "smallest" unit in the sense that the scheduler can't break it up into smaller pieces to run concurrently. That doesn't mean that it's the smallest sequence of instructions that can exist on the hardware, just the scheduler is not able to divide it up into smaller "streams" of instructions that can run independently. Whereas a process can be running on more than one core (or be run "out of order" on a single core) if it has more than one thread in it.

gadamico commented 8 years ago

That helps. Thanks, Sean.