Threads Flashcards
Imagine RAM containing one piece of code and two programs sharing that piece of code. How will the CPU see this?
Each of the two programs has a PCB, so for the CPU, there are two different programs executing.
Imagine RAM containing one piece of code and two programs sharing that piece of code. How will the RAM see this?
There is only one piece of code in memory so there is only one program.
What is a thread?
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.
-Wikipedia
So a thread is something like: RAM containing one piece of code and two programs sharing that piece of code.
Imagine RAM containing one piece of code and two programs sharing that piece of code.
What does this mean?
Agnostic
Part of the code that is compatible with two different programs.
What parts of this code is agnostic?
- Call printf
Let P1 and P2 share the following code. What happens when P1’s quanta finishes and P2 enters?
All the information saved in the registers for P1 has to be stored in the PCB since P2 will use those same registers but with different values.
*What is overhead?
Multi-Tasking
Each process has only ONE execution.
Multi-Threading
Each process has multiple processes running.
ex: In a browser, you can have multiple tabs.
Spooling
Spooling allows programs to ”hand-off” work to be done by the peripheral and then proceed to other tasks, or to not begin until input has been transcribed.
-Wikipedia
Is this multi-tasking or multi-threading, why?
Multi-tasking, since each process has its own spooler.
Is this spooler a multi-tasking version or multi-threading version, why?
Multi-threading since the processes are sharing a spooler.
In the multi-threading version of a spooler, what could we use to manage who enters the spooler first?
A queue
True or false,
In the multi-thread version of the spooler quanta still applies
True