0

Lets say I have 4 core on my machine and I have a process that spawns 4 threads, while this is the current process scheduled, are all 4 of those cores reserved for the process' 4 threads?

jack sexton
  • 1,227
  • 1
  • 9
  • 28
  • Linux actually [schedules threads](http://stackoverflow.com/questions/15601155/does-linux-schedule-a-process-or-a-thread), not processes. When we talk about scheduling processes, we usually refer to classic, simplified single threaded processes. – that other guy Jul 24 '16 at 00:41

2 Answers2

1

That is a very complex question. However, I can help. As a general rule, 1 process only uses 1 core. Actually, 1 thread can only be executed by 1 core. If you have a dual core processor, it is literally 2 CPUs stuck together in the same pc. These are called physical processors. These physical proessors execute 1 thread. Although, some CPUs have 2 physical cores but are capable of running 4 threads simultaneously. These extra 2 threads are run on logical cores. They do not physically exist but logically exist to the cpu.

If by process you mean thread then yes 1 process 1 core. And you can run 4 threads on a cpu with 4 compute cores (the name with includes physical and logical cores because a single core cpu may only have 1 compute core).

If by process you mean program or process in the processes tab in the task manager, then it depends on how the program is written.

Judging by your question, if a process spawns 4 threads it depends at what place it is in the pool. There are thousands of threads waiting to be executed. The threads from each program or executable file do not have to be executed at the same time.

User123
  • 31
  • 1
  • 6
1

The 4 threads of your process are scheduled independently - the process itself isn't scheduled.

If all 4 threads are runnable at the same time, and there's no other higher priority runnable threads in the system, then all 4 threads may be scheduled simultaneously on your 4 cores.

caf
  • 233,326
  • 40
  • 323
  • 462