开发者

multithreading and multiprocessing

I am trying to understand basic OS concepts

Want to know if my understanding is right multi-processing Example: I invoke A.exe on my machine. I invoke another instance of it again. So there would be two A.exe on the RAM which are called processes and the OS would do multi-processing between them by means of context switching and blah blah

Multi-threading Example: A.exe consitutes 2 things say program C and D . Assuming invoking A.exe means running C and D simultaneously. In that case 1. program A would call C and D as thread and s开发者_开发百科pan or start them as soon as A.exe is loaded. 2. C and D are threads and when process A.exe is given a chance to execute, only then multi-threading between C and D happens 3. C and D share the same process space alloted for A.

Is this correct?


Largely correct

  • it is not required that a process creates all its threads at the beginning; they can be created as needed, and as many as needed can be created
  • the operating system multi-tasks between threads; many processes consist of a single thread, others might consist of several. The operating system has complicated ways of working out how to balance the CPU time of all the threads in the system based upon whether they need to run and what their priority is and such; its not as simple as you describe in the system, and its not based upon the process they are part of (except when that is part of the weighting system in the scheduler)

Multi-threading allows the threads to share state easily - there is no 'memory protection' between the threads in the same process

Multiple processes does not allow threads to share state except explicitly e.g. by passing messages, sharing file handles or explicitly shared memory.


Yes. You are correct

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜