Is a thread nothing but a sequence of machine instructions?

60 Views Asked by At

I was watching this video from Computerphile and at 10:03 you can see this:

enter image description here

where T1 and T2 are threads, and under them are machine instructions.

Does it mean a thread is basically made up of a sequence of machine instructions?

Already tried to read online articles and watched youtube videos.

2

There are 2 best solutions below

0
Noob_Guy On

Well, at the end of the day, everything that a processor executes is a machine instruction from its instruction set (at least at micro-architecture level of abstraction; if you want to go further at logic gate level then it's bits; if you want to go further at electronics level then it's voltages, etc.).

So yes, a thread is nothing but a sequence of machine instructions as you saw in that video.

2
Stephen C On

No it is not just a sequence of instructions.

The thread also includes the (thread-specific) context in which the instructions are executed. The context includes the thread's stack / stack frames, and the CPU registers for the core that is "running" the thread.

And in some programming languages, other things are part of a thread's state. For example, Java provides thread-local variables ... but that's beyond the scope of your question.