瀏覽單個文章
沒問題
Major Member
 

加入日期: Dec 2015
文章: 208
引用:
作者anderson1127
OS裡的thread , 之所以是稱之為線程 , 就是因為它不同於sub-procedure !!

就我所瞭解的OS裡的thread , 本身不含任何的程式碼 ,它只是很單純的data structure
更簡單說,它只是資料而已,所以才稱為thread , 如果它本身含有程式碼+資料 , 那就直接稱為
process/procedure就好,沒事去多弄一個名稱thread , 來搞得我好亂做什麼呢??

如果,你不去套用任何的現成Library 單純從無到有來設計thread化的program , 那真的如同設計一個OS 一樣的不容易 , 同樣的如果你能夠設計出來,就真的代表你徹底搞清楚何謂thread !!


the reason we divided a program into multiple sub-procedure is to execute multiple duplicated copy of data.

like i said above, you want to see two movies at the same time.
you can have two DVD player programs that perform each DVD movie at the same time.

but it would be inefficient. the best way for you to do the same is to make the DVD player program become a sub-procedure or a function.
you can have unlimited DVD data you want in a program which is performed by the sub-procedure or function.

imaging. you got one video player software which is playing a DVD movie and a BD movie at the same time.
do you think that the DVD decoder is able to decode BD data?
you might say why i need to use DVD decoder to decode BD data? why do i not use BD decoder to decode DVD data.

the key point is you will never know what your thread will need to do.
you can think that there are two threads only performing the function of windowed screen separately for DVD and BD.
however, there is also a thread performing the task of issuing subtitles onto each windowed screen.

do you think that the function (or you can call the function a thread) of issuing subtitles and performing windowed screen would be the same?

the answer is NO.
although they are in the same video player software.
舊 2018-11-06, 06:11 PM #36
回應時引用此文章
沒問題離線中