开发者

Multithreading vs virtual process

There's three types of control flow model, single threaded, virtual process and multithreaded process. here's what has written in the power point which I study form

Virtual processes. This is based on a single threaded model but gives the appearance of concurrent execution. a controller component schedules the execution of the other components and gives them control. The scheduling can be performed periodically or based on events. This model is based on a logical decomposition of activities in s开发者_如何学Cimple steps whose execution requires only short intervals of time.

I couldn't understand it and couldn't understand the difference between multithreading process and vp. can some one help?

EDIT here the chapter of the book which I mention the section above form http://www.mediafire.com/?ru82i0nvp12qw6t


This term "virtual process" is unusual but based on your description I can give 2 real-world examples of using each.

For multithreading, imagine you have a lot of data in memory and want to perform some calculations on it... you can split that data up and have seperate threads (1 per CPU core, ideally) simultaneously working on different chunks of the data. This way, the calculations will be done faster based on how many threads you create.

For 'virtual process', imagine you need to retrieve 20 files from remote servers... most of the CPU 'work' involved in this is just sitting around waiting for bytes to arrive from the remote network. Creating separate threads to download each of these files would not make the files arrive any faster. If anything, having extra threads that the OS needs to constantly switch between (and it will switch a LOT because most of the time each thread will just say 'im still waiting' and then cede control). So, in this case it's better to have a single thread doing all of the downloading, cycling internally between each of the download tasks to read incomming data off of their buffers.


Your virtual process looks to me like event driven programming. Google for eg. 'threads vs events', the first link you get is quite fine comparison.

EDIT: Here's another comparison I've found in bookmarks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜