<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-981803281592391235</id><updated>2011-04-21T16:29:52.729-07:00</updated><title type='text'>โปรเซสสื่อประสาน (Cooperating Process)</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-4674895831797148543</id><published>2007-12-06T21:36:00.001-08:00</published><updated>2007-12-06T21:36:30.622-08:00</updated><title type='text'>โปรเซสสื่อประสาน (Cooperating Process)</title><content type='html'>โปรเซสสื่อประสาน (Cooperating Process) มีดังนี้&lt;br /&gt;- การแชร์ข้อมูลข่าวสาร เนื่องจากผู้ใช้จะมีความต้องการข้อมูลเดียวกันในเวลานั้นๆ เช่น ( ต้องการใช้ไฟล์ที่ระบบแชร์ไว้ )&lt;br /&gt;- การเพิ่มความเร็วมรการคำนวณ ด้วยหลักการง่ายๆ ที่ว่า ถ้าเราต้องการรันโปรแกรมพิเศษให้เร็วขึ้น เราจะต้องแบ่งโปรแกรมนั้นออกเป็นส่วยย่อยๆ แล้วเอ็กซิคิวต์แต่ละส่วนพร้อมกับงานอื่น&lt;br /&gt;- ความสะดวก สิ่งทีเกิดจากความต้องการของผู้ใช้แต่ละคนที่ต้องการทำงานหลายอย่างในเวลาเดียวกัน เช่น ต้องการทั้งแก้ไขข้อมูล พิมพ์ และคอมไพล์งานพร้อมๆ กัน ทำให้มีความจำเป็นต้องประสานกับโปรเซสอื่น &lt;a name="jjj"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-4674895831797148543?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/4674895831797148543/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=4674895831797148543' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4674895831797148543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4674895831797148543'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/cooperating-process.html' title='โปรเซสสื่อประสาน (Cooperating Process)'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-8202399733371741973</id><published>2007-12-06T21:36:00.000-08:00</published><updated>2007-12-06T21:36:02.940-08:00</updated><title type='text'>การติดต่อระหว่างโปรเซส ( InterProcess Communication : IPC )</title><content type='html'>การติดต่อระหว่างโปรเซส ( InterProcess Communication : IPC ) มีดังนี้&lt;br /&gt;1. โครงสร้างพื้นฐาน&lt;br /&gt;IPC สนับสนุนกลไดเพื่อให้โปรเซสสามารถติดต่อซึ่งกันและกันได้อย่างมีประสิทธิภาพ IPC สนับสนุนอบ่างน้อย 2 ประการคือ กาส่งแมสเสจ และรับแมสเสจ ซึ่งการสนับสนุนจะต้องคำนึงถึงสิ่งเหล่านี้คือ&lt;br /&gt;- จะสร้างลิงค์อย่างไร&lt;br /&gt;- ลิงค์ที่สร้างนั้นสัมพันธ์กับโปรเซสมากกว่า 2 โปรเซสหรือไม่&lt;br /&gt;- ระหว่างโปรเซสทั้งสองจะมีกี่ลิงค์&lt;br /&gt;- ความจุของลิงค์เป็นเท่าไร&lt;br /&gt;- ลิงค์นั้นมีบัฟเฟอร์หรือไม่&lt;br /&gt;- ลิงค์เป็นแบบทางเดียวหรือสองทิศทาง โดยที่ลิงค์แบบทางเดียวจะให้มีการรับส่งแมสเสจให้ทางเดียว คือโปรเซสสามารถรับได้ หรือโปรเซสใดรับก็รับอย่างเดียวจะส่งไม่ได้ ส่วนการลิงค์แบบหลายโปรเซสจะต้องมีอย่างน้อย 1 โปรเซสที่ทำหน้าที่รับแมสเสจ&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-8202399733371741973?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/8202399733371741973/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=8202399733371741973' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/8202399733371741973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/8202399733371741973'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/interprocess-communication-ipc.html' title='การติดต่อระหว่างโปรเซส ( InterProcess Communication : IPC )'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-2722199355291823350</id><published>2007-12-06T21:35:00.000-08:00</published><updated>2007-12-06T21:35:23.715-08:00</updated><title type='text'>2.วิธีการติดต่อ มี 2 วิธีมีคุณสมบัติที่น่าสนใจดังนี้</title><content type='html'>Send (B, message) จะเป็นการส่งแมสเสจไปยังโปรเซส B&lt;br /&gt;Reciece (A , message )  จะเป็นการรับแมสเสจจากโปรเสจ A&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-2722199355291823350?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/2722199355291823350/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=2722199355291823350' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2722199355291823350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2722199355291823350'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/2-2.html' title='2.วิธีการติดต่อ มี 2 วิธีมีคุณสมบัติที่น่าสนใจดังนี้'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-722357080403021497</id><published>2007-12-06T21:34:00.000-08:00</published><updated>2007-12-06T21:34:16.122-08:00</updated><title type='text'>- การติดต่อทางตรง (direct communication)</title><content type='html'>การติดต่อแบบนี้จะต้องกำหนดชื่อเฉพาะในการติดต่อทั้งผู้รับและผู้ส่ง ยกตัวอย่างเช่น ถ้าต้องการส่งแมสเสจจาก A ไป B จะมีการกำหนดรูปแบบคือ   ลิงค์แบบนี้มีคุณสมบัติดังนี้&lt;br /&gt;-  การสร้างลิงค์จะเป็นแบบอัตโนมัติในระหว่างคู่ของโปรเซสที่ต้องการติดต่อ ( ในที่นี้คือ A กับ B) โปรเซสจะทราบหมายเลขโปรเซสที่จะติดต่อด้วย&lt;br /&gt;-  ลิงค์หนึ่ง ๆ จะมีความสัมพันธ์เฉพาะโปรเซสสองโปรเซสเท่านั้น&lt;br /&gt;-  ลิงค์นี้เป็นได้ทั้งทิศทางเดียว และสองทิศทาง แต่ปกติจะเป็นแบบสองทิศทาง&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-722357080403021497?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/722357080403021497/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=722357080403021497' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/722357080403021497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/722357080403021497'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/direct-communication.html' title='- การติดต่อทางตรง (direct communication)'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-6439322858517162877</id><published>2007-12-06T21:33:00.000-08:00</published><updated>2007-12-06T21:33:27.879-08:00</updated><title type='text'>- การติดต่อทางอ้อม (indirect communication )</title><content type='html'>การติดต่อแบบนี้โปรเซสทั้งสองที่ต้องการจะติดต่อกันจะติดต่อกันผ่านทางเมลล์บ็อกซ์ (Mailbox) หรืออาจเรียกว่าเป็นการติดต่อทางพอร์ต (port) และเมลล์บ็อกซ์ที่ใช้ในการติดต่อกันนี้จะต้องมีการแชร์เมลล์บ็อกซ์ไว้ก่อนด้วย รูปแบบคำสั่งการรับ - ส่งข้อมูลผ่านเมลล์บ็อกซ์เป็นเช่นนี้&lt;br /&gt;Send(B, message) เป็นการส่งแมสเสจไปยังเมลล์บ็อกซ์ B&lt;br /&gt;Receive(A, message) เป็นการรับแมสเซสจากเมลล์บ็อกซ์ A&lt;br /&gt;ลิงค์แบบนี้จะมีคุณสมบัติดังนี้&lt;br /&gt;w จะมีการสร้างลิงค์ระหว่างโปรเซสที่มีการแชร์เมลล์บ็อกซ์เท่านั้น&lt;br /&gt;w ลิงค์หนึ่ง ๆ อาจจะมีความสำพันธ์มากกว่าสองโปรเซสก็ได้&lt;br /&gt;w ระหว่างโปรเซสแต่ละคู่นั้นอาจมีหลายลิงค์ที่แตกต่างกันได้ แต่ละลิงค์จะมีเพียงเมลล์บ็อกซ์เดียว&lt;br /&gt;w การลิงค์อาจเป็นทิศทางเดียว หรือสองทิศทางก็ได้&lt;br /&gt;ตอนนี้เพื่อความเข้าใจมากยิ่งขึ้น สมมุติว่าทั้งโปรเซส p1, p2 และ p3 มีการแชร์เมลล์บ็อกซ์ A ไว้โปรเซส p1 จะส่งแมสเสจไปยัง A ในขณะที่โปรเซส P2 และ P3 ต้องการรัยแมสเสจจาก A คำถามก็คือว่าโปรเซสใดจะรับแมสเสจที่ส่งจาก A คำถามอาจแก้ได้หลายวิธีดังนี้&lt;br /&gt;w ยอมให้มีการลิงค์ทั้งสองโปรเซส&lt;br /&gt;w ยอมให้มีการรับแมสเสจได้เพียงครั้งละ 1 โปรเซส&lt;br /&gt;w ยอมให้ระบบเลือกว่าโปรเซสใดที่จะเข้ารับแมสเสจ&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-6439322858517162877?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/6439322858517162877/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=6439322858517162877' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6439322858517162877'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6439322858517162877'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/indirect-communication.html' title='- การติดต่อทางอ้อม (indirect communication )'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-4430590010177439238</id><published>2007-12-06T21:32:00.000-08:00</published><updated>2007-12-06T21:32:26.638-08:00</updated><title type='text'>- รูปแบบของเมลล์บ็อกซ์</title><content type='html'>- รูปแบบของเมลล์บ็อกซ์   รูปแบบการใช้เมลล์บ็อกซ์มี 3 แบบคือ&lt;br /&gt;เมลล์บ็อกซ์แบบคิว (Queue Mailbox)&lt;br /&gt;เมลล์บ็อกซ์แบบไปป์ (Pipe Mailbox)&lt;br /&gt;เมลล์บ็อกซ์แบบแต็ก (Stack Mailbox)&lt;br /&gt;  เมลล์บ็อกซ์แบบคิว โครงสร้างของเมลล์บ็อกซ์แบบนี้เป็นโครงสร้างที่ดึงข้อมูลออกจากเมลล์บ็อกซ์ตามลำดับก่อน - หลังของข้อมูลที่ส่งมา นั่นคือข้อมูลใดที่ส่งเข้ามาในเมลล์บ็อกซ์ก่อนก็จะถูกดึงออกไปก่อน ส่วนข้อมูลใดส่งเข้ามาภายหลังก็จะถูกดึงออกไปภายหลัง อาจเรียกการทำงานแบบนี้ว่า FIFO (First In First Out) ลักษณะโครงสร้างเมลล์บ็อกซ์แบบคิว&lt;br /&gt;เมลล์บ็อกซ์แบบไปป์ โครงสร้างของเมลล์บ็อกซ์แบบนี้เป็นโครงสร้างของโครงสร้างแบบคิว คือการดึงข้อมูลจะเป็นในลักษณะ ที่ข้อมูลส่งเข้ามาก่อนจะถูกดึงออกไปก่อน ข้อมูลใดส่งเข้ามาภายหลังก็จะถูกดึงออกไปใช้งารภายหลัง แต่ข้อแตกต่าง ระหว่างเมลล์บ็อกซ์แบบคิวกับเมลล์บ็อกซ์แบบไปป์คือเมลล์บ็อกซ์แบบคิวจะมีขนาดคงที่ เมลล์บ็อกซ์จะขยายตัวอัตโนมัติ ลักษณะโครงสร้างของเมลล์บ็อกซ์แบบไปป์&lt;br /&gt;เมลล์บ็อกแบบสแต็ก โครงสร้างของเมลล์บ็อกซ์แบบนี้เป็นโครงสร้างตรงข้ามกับเมลล์บ็อกซ์แบบคิวในการดึงข้อมูล นั่นก็คือข้อมูลใดส่งเข้ามาเมลล์บ็อกซ์ก่อนจะถูกดึงออกไปใช้งานภายหลัง โดยจะนำข้อมูลที่ส่งเข้ามาภายหลังออกไปใช้การก่อน อาจเรียกการทำงานแบบนี้ว่า FILO(First In Last Out) ลักษโครงสร้างเมลล์บ็อกซ์ แบบสแตก&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-4430590010177439238?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/4430590010177439238/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=4430590010177439238' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4430590010177439238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4430590010177439238'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/blog-post_7108.html' title='- รูปแบบของเมลล์บ็อกซ์'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-7412761347799552677</id><published>2007-12-06T21:31:00.000-08:00</published><updated>2007-12-06T21:31:35.953-08:00</updated><title type='text'>3 . การจัดบัฟเฟอร์</title><content type='html'>ในการสร้างลิงค์ นอกจากจะเป็นการกำหนดเส้นทางข้อมูลแล้ว ลิงค์ยังมีความจที่เป็นตัวเลขแสดงจำนวนแมสเสจที่สามารถเก็บไว้ ชั่วคราวได้ คุณสมบัตินี้อาจจะมองว่าเป็นคิวของแมสเสจที่ผูกติดกับลิงค์ก็ได้ โดยพื้นฐานมีความจุ 3 ลักษณะคือ&lt;br /&gt;w ความจุศูนย์ (Zero capasity) ความจุแบบนี้จะทำให้มีคิวขนาดสูงสุดเป็น 0 ดังนั้นลิงค์จะไม่มีแมสเสจรออยู่เลย ในกรณีผู้ส่งจะต้อง รอจนกว่าผู้รับแมสเสจ โปรเซสทั้งสองจะต้องซินโครไนซ์เพื่อให้เกิดการถ่ายโอนแมสเสจ การซินโครไนซ์แบบนี้เรียกว่า rendezvous&lt;br /&gt;w ความจุแบบมีขอบเขต (Bounded capasity) ความจุแบบนี้จะทำให้คิวมีขนาดคงที่เป็น n ดังนั้นจะมีแมจเสจสูงขึ้น n แมสเซสที่เก็บไว้ในคิว ถ้าคิวยังไม่เต็มเมื่อแมสเสจใหม่จะถูกส่งเข้ามาหลังจากนั้นจะเข้าไปอยู่ในคิว&lt;br /&gt;w ความจุไม่มีขอบเขต (Unbounded capasity) ความจุแบบนี้ให้คิวมีขนาดไม่คงที่ทำให้แมสเสจถูกเก็บไว้เสมอ ผู้ส่งไม่ต้องรอเวลาเลย&lt;br /&gt;ตัวอย่างเช่น ถ้าโปรเซส P ส่งแมสเสจไปยังโปรเซส Q และสามารถเอ็กซิคิวต์ ได้ต่อไปเฉพาะหลังจากที่แมสเสจได้รับไปแล้ว โปรเซส P&lt;br /&gt;จะมีขั้นตอนดังนี้&lt;br /&gt;Send (Q, message);&lt;br /&gt;receive (Q, message);&lt;br /&gt;โปรเซส Q จะเอ็กซิคิวคำสั่ง&lt;br /&gt;receive (P, message);&lt;br /&gt;send (P, acknowledgment);&lt;br /&gt; การรับ - ส่งแมสเสจระหว่างโปรเซส P และโปรเซส Q ในลักษณะนี้เรียกว่า asynchroncus อย่างไรก็ตามยังมี 2-3 กรณี ที่ไม่เข้ากลุ่มใดตามที่กล่าวมา แล้วนี้&lt;br /&gt;w การส่งแมสเสจจองโปรเซสได้โดยไม่ต้องคอย กรณีนี้ถ้าผู้รับยังไม่ได้รับแมสเสจก่อนที่จะส่งแมสเสจอื่น&lt;br /&gt;w การส่งแมสเสจของโปรเซสจะล่าช้าออกไปจนกว่าโปรเซสจะได้รับคำตอบ วิธีการนี้นำมาใช้เป็นระบบปฏิบัติการที่ชื่อ Thoth โดยในระบบนี้จะมีขนาดที่แน่นอน&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-7412761347799552677?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/7412761347799552677/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=7412761347799552677' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7412761347799552677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7412761347799552677'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/3.html' title='3 . การจัดบัฟเฟอร์'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-3486347817227280430</id><published>2007-12-06T21:30:00.001-08:00</published><updated>2007-12-06T21:30:59.241-08:00</updated><title type='text'>4. เงื่อนไขยกเว้น</title><content type='html'>ระบบแมสเสจมีประโยชน์มากในสภาพแวดล้อมแบบกระจายซึ่งโปรเซสอาจจะอยู่บนเครื่องอื่น ในสภาพแวดล้อมที่กล่าวถึงงความน่าจะ เป็นที่เกิดข้อผิดพลาดระหว่างการติดต่อสื่อสารและโปรเซสจะมากว่าในสภาพแวดล้อมที่เป็นเครืองเดียว สำหรับสภาพแวดล้อมที่ป็นเครื่องเดียว แมสเสจจะอยู่ในหน่วยความจำที่แชร์ ถ้าเกิด&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ข้อผิดพลาดเกิดขึ้นระบบโดยรวมจะล่ม แต่สำหรับในระบบกระจายแมสเสจจะถ่ายโอนไปตามสาย&lt;br /&gt;การเกิดข้อผิดพลาดที่เครื่องใดเครื่อหนึ่งไม่จำเป็นที่ระบบโดยรวมจะล่มก็ได้ทั้งระบบที่ศูนย์กลางหรือระบบกระจายข้อผิดพลาดอาจจะได้รับการแก้ไข ตอนนี้เรามาพิจารณาเงื่อนไขที่ระบบต้องดูแลแมสเสจ&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-3486347817227280430?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/3486347817227280430/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=3486347817227280430' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/3486347817227280430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/3486347817227280430'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/4.html' title='4. เงื่อนไขยกเว้น'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-8014919668436300192</id><published>2007-12-06T21:30:00.000-08:00</published><updated>2007-12-06T21:30:01.585-08:00</updated><title type='text'>- การสิ้นสุดของโปรเซส</title><content type='html'>ถ้าผู้รับหรือผู้ส่งแมสเสจสิ้นสุดก่อนแมสเซสจะเอ็กซิคิวต์ ในสภาวะแบบนี้จะทำให้แมสเสจจะถูกกำจัดทำให้ผู้รับไม่ได้รับแมสจ หรือผู้ส่งไม่ได้&lt;br /&gt;ส่งแมสเสจ ลองพิจารณา 4 กรณีดังนี้&lt;br /&gt;-  ผู้รับโปรเซส P อาจจะรอจากโปรเซส Q ที่สิ้นสุดไปแล้ว ถ้าไม่มีแอ็กชันใด ๆ เกิดขึ้น โปรเซส p จะถูกบล็อกตลอดไป ในกรณีนี้ระบบอาจ จะสั่งให้ P สิ้นสุด หรืออาจจะแจ้งให้ P ทราบว่า Q สิ้นสุดไปแล้วก็ได้&lt;br /&gt;-โปรเซส P อาจจะส่งแมสเสจไปยังโปรเซส Q ที่สิ้นสุดไปแล้ว ในรูปการจัดบัฟเฟอร์แบบอัตโนมัติจะไม่เกิดอันตรายใด ๆ โดย P ยังคงเอ็กซิคิว&lt;br /&gt;ต่อไป&lt;br /&gt;-  ถ้าโปรเซส P ต้องการทราบว่าแมสเสจของตนนั้นโปรเซส Q เอ็กซิคิวหรือไม่ จะต้องมีการโปรแกรมพิเศษสำหรับการแจ้งให้ทราบ แต่ในกรณี&lt;br /&gt;- ที่ไม่มีบัฟเฟอร์ โปรเซส P จะถูกบล็อกตลอดไปเช่นเดียวกีบข้อ 1 ระบบอาจจะสั่งให้ P สิ้นสุด หรืออาจะแจ้งให้ P ทราบว่า Q สื้นสุดไปแล้วก็ได้&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-8014919668436300192?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/8014919668436300192/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=8014919668436300192' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/8014919668436300192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/8014919668436300192'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/blog-post_1103.html' title='- การสิ้นสุดของโปรเซส'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-2308183612258535594</id><published>2007-12-06T21:28:00.001-08:00</published><updated>2007-12-06T21:28:45.935-08:00</updated><title type='text'>- การสูญหายของแมสเสจ</title><content type='html'>แมสเสจจากโปรเซส P ที่ส่งไปยังโปรเซส Q อาจจะสูญหายระหว่างทางการสื่อสารก็ได้ซึ่งอาจจะเป็นข้อผิดพลาดด้วยฮาร์ดแวร์สายสื่อสาร มี 3 วิธี  พื้นฐานในการจัดเหตุการณ์นี้&lt;br /&gt;1. ระบบปฏิบัติการมีหน้าที่รับผิดชอบในการตรวจสอบการเสียหายนี้เพื่อส่งแมสเสจไปใหม่&lt;br /&gt;2. โปรเซสที่ทำหน้าที่ส่งแมสเสจมีหน้าที่รับผิดชอบในการตรวจสอบการสูญหายเพื่อส่งแมสเสจใหม่ถ้าต้องการอีก&lt;br /&gt;3. ระบบปฏิบัติการมีหน้าที่รับผิดชอบในการตรวจสอบการสูญหายนี้ หลังจากนั้นจะแจ้งให้โปรเซสที่ทำหน้าที่ส่งแมสเสจที่เกิดการสูญหายเพื่อให้ส่งแมสเสจไปใหม่&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-2308183612258535594?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/2308183612258535594/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=2308183612258535594' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2308183612258535594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2308183612258535594'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/blog-post_06.html' title='- การสูญหายของแมสเสจ'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-2681752694370080111</id><published>2007-12-06T21:28:00.000-08:00</published><updated>2007-12-06T21:28:02.660-08:00</updated><title type='text'>การซินโดรไนซ์โปรเซส (Process Synchronization)</title><content type='html'>การซินโดรไนซ์โปรเซส (Process Synchronization)&lt;br /&gt;โดยปกติโปรเซสส่วนใหญ่ในระบบจะไม่มีควาทเกี่ยวข้องกัน ต่างคนต่างเอ็กซิคิวต์ ลักษณะความเป็นอิสระนี้เรียกว่า (Asynchronous) แต่มีบางโปรเซสที่มีความสัมพันธ์กันนอกจากการติดต่อสื่อสารระหว่างโปรเซส (InterProcess Communication) ที่กล่าวไปแล้วยังมีการเข้าจังหวะของโปรเซสอีกด้วย การเข้าจังหวะของโปรเซสหรืออาจเรียกว่าโปรเซสนั้นเกิดการไซโครไนซ์กัน การไซโครไนซ์จะหมายถึงการทำงานโปร2โปรเซสที่ต้องมีการเกี่ยวข้องกันอาจเป็นเพราะรีซอร์สร่วมกัน หรืออาจจะเป็นการรอเอ็กซิคิวต์โปรเซสหลังจากที่โปรเซสอื่นเอ็กซิคิวต์แล้ว&lt;a name="lll"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-2681752694370080111?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/2681752694370080111/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=2681752694370080111' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2681752694370080111'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2681752694370080111'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/process-synchronization.html' title='การซินโดรไนซ์โปรเซส (Process Synchronization)'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-7354147584338628639</id><published>2007-12-06T21:27:00.000-08:00</published><updated>2007-12-06T21:27:29.572-08:00</updated><title type='text'>1. โครงสร้างพื้นฐานการซินโครไน์</title><content type='html'>โปรเซส ที่ทำงานร่วมกับโปรเซสอื่นใน การเอ็กซิคิวต์จำเป็นต้องอาศัยการซินโครไนซ์ที่เหมาะสม เพื่อให้การทำงานถูกต้องที่กล่าวมาแล้วนั้น ในการซินโครไนซ์โปรเซสไม่ใช่เรื่องที่ทำได้ง่ายมีโครงสร้างและสิ่งที่จะเกิดขึ้นในการซินโครไนซ์ที่น่าสนใจ&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-7354147584338628639?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/7354147584338628639/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=7354147584338628639' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7354147584338628639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7354147584338628639'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/1.html' title='1. โครงสร้างพื้นฐานการซินโครไน์'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-4927239738233065870</id><published>2007-12-06T21:25:00.000-08:00</published><updated>2007-12-06T21:25:32.255-08:00</updated><title type='text'>1.1 Race Condition</title><content type='html'>ในบางระบบปฏิบัติการ โปรเซสที่ทำงานร่วมกันอาจมีการแชร์รีซอร์ส เช่น หน่วยความจำ หรือสื่อจัดเก็บข้อมูล หรือแชร์ไฟล์ซึ่งโปรเซสทั้ง2 สามารถอ่านหรือเขียนรีสอร์สได้พร้อมกันทำให้ผลลัพธ์เกิดการผิดพลาดขึ้นอยู่ว่าโปรเวสใดเข้ามาใช้งานก่อนสภาวะที่เกิดขึ้นนี้เรียกว่า (Race Condition)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-4927239738233065870?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/4927239738233065870/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=4927239738233065870' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4927239738233065870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4927239738233065870'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/11-race-condition.html' title='1.1 Race Condition'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-7407566547431925456</id><published>2007-12-06T21:24:00.000-08:00</published><updated>2007-12-06T21:24:52.732-08:00</updated><title type='text'>1.2 MutualExclusionและCriticalRegion</title><content type='html'>ถ้าเราจะแก้ไขสภาวะRaceConditionได้อย่างไรคำตอบ ก็คือเราต้องหยูดไม่ให้เกิดการเอ็กซิคิวต์โปรเซสที่สองในขณะเอ็กซิคิวต์โปรเซสแรกอยู่ ถ้ายังมีโปรเซสแรกครอบครองรีซอร์สอยู่โดยจะต้องรอจนกว่าโปรเซแรกโปรเซแรกทำงานเสร็จเรียบร้อยเพื่อป้องกันไม่ให้เกิดข้อผิดพลาด วิธีป้องกันไม่ให้โปรเซสอื่นเข้าไปใช้รีซอร์สขณะที่โปรเซสใดๆครอบครองรีซอร์สนั้นเรียกว่าMutualExclusion หรืออาจเรียกว่า การกีดกัน&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-7407566547431925456?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/7407566547431925456/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=7407566547431925456' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7407566547431925456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/7407566547431925456'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/12-mutualexclusioncriticalregion.html' title='1.2 MutualExclusionและCriticalRegion'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-1580537281183009993</id><published>2007-12-06T21:21:00.001-08:00</published><updated>2007-12-06T21:21:52.454-08:00</updated><title type='text'>1.3 Mutual Exclusion with busy waiting</title><content type='html'>เนื่องจากในสภาวะ mutual Exclusion จะยอมไห้มีการครองรีซอร์ได้ครั้งละ1โปรเซส ทำไห้โปรเซสอื่นต้องรออยู่ภายนอก Critical Regionแต่การรอขอโปรเซสก็ยังเป็นการครอบครองเวลาซีพี ทำไห้เสียประโยชร์เนื่องจากไม่ได้งานอะไรเลย การรอของโปรเซสก็ยังเป็นการครอบครองซีพียูทำให้เสียประโยชน์เมื่อไม่ได้งานใด ๆ เลยการรอของโปรเซสในลักษณะนี้เรียกว่า busy waiting&lt;br /&gt;-- Disable Interrupt  วิธีการนี้เป็นการยกเลิกอินเตอร์รัพต์ ทำให้ซีพียูทำงานได้อย่างต่อเนื่องโดยไม่สนใจอินเตอร์รัพต์ใด ๆ เลย ทำให้โปรเซสที่อยู่ใน Critical Region ได้เอ็กซิคิวต์จนเสร็จเรียบร้อยแล้วจะได้ไม่เกิดRaceCondition ขึ้นมาได้&lt;br /&gt;ข้อเสียของวิธี Disable Interrupt มี 3 ประการ&lt;br /&gt;• ถ้าใช้คำสั่ง Disable Interrupt ไว้ตอนต้นแต่ลืมใช้คำสั่ง Able Inteerrupt ไว้ท้ายสุดของโปรเซสของผู้ใช้&lt;br /&gt;• ไม่นิยมใช้ใน User Mode&lt;br /&gt;• คำสั่ง Disable Inteerrupt จะมีผลกับระบบที่ใช้ซีพียูเพียงตัวเดียว&lt;br /&gt;-- Lock Variable&lt;br /&gt;วิธีการนี้เป็นการใช้ซอฟแวร์ในการตรวจสอบเกิด Race Condition โดยการกำหนดตัวแปรขึ้นมา 1 ตัว โดยใช้ตัวแปรนี้จะคอยตรวจสอบว่ามีโปรเซสใดอยู่ใน Critical Region&lt;br /&gt;-- Strict Alternation วิธีนี้เป็นการสลับกันเพื่อเข้า Critical Region ระหว่างโปรเซสสองโปรเซส เช่น ถ้าโปรเซส A และ B ต้องการเข้า Critical Region โปรเซส A ที่มาก่อนก็จะได้เข้า Critical Region ก่อนหลังจากนั้นจะให้โปรเซส B ได้เข้าCritical Region บ้าง&lt;br /&gt;-- Peterson's Solution  ถึงแม้เด็กเกอร์จะเป็นบุคคลแรกที่ค้นวิธีแก้ปัญหา Mutual Exclusion ที่ไม่ใช้วิธีสลับเวลาแต่อัลกอริทึมที่นำมาการแก้ปัญหาของปีเตอร์สันเป็นวิธีที่ง่ายกว่า&lt;br /&gt;-- TSL InstructionTSL Instruction หรือ Test Set Lock Instruction เป็นคำสั่งที่ทำให้เกิด Mutual Exclusion ที่ช่วยแก้ปัญหา Lock Variable โดยการทำ Test Set Lock เสร็จเป็นขั้นตอนเดียววิธีการก็คือจะอ่านค่าจากหน่วยความจำมาเก็บไว้ในรีจีสเตอร์ แล้ว Set ค่าในหน่วยความจำเป็น 1 ในลักษณะคำสั่งTSL RX,LOCKการทำงานจะเริ่มจากการอ่านค่าจากหน่วยความจำที่แอ็ดเดรสLOCKมาเก็บไว้ที่รีจีสเตอร์ RX แล้วเก็บค่าที่ไม่ไช่ 0 ( ในที่นี้ใช้ 1 ) ลงในแอ็ดเดรสนั้น การอ่านค่าและการเก็บค่าลงในหน่วยความจำขณะนั้นจะไม่มีโปรเซสใดสามารถใช้หน่วยความจำนั้นได้จนกว่าคำสั่งนั้นจะเสร็จสิ้น อาจกล่าวได้ว่าซีพียูจะเอ็กซิคิวต์คำสั่งTSLเพื่อล็อกไม่ให้ซีพียูอื่นใช้หน่วยความจำจนกว่างานนั้นจะเสร็จเรียบร้อยการใช้คำสั่ง TSL จะต้องแชร์ตัวแปร LOCK ในการใช้หน่วยความจำที่แชร์เมื่อแปรตัวแปรLOCKมีค่าเป็น0โปรเซสอื่นจะเซ็ตให้มีค่าเป็น 1 เพื่อจะใช้คำสั่งTSL แล้วจะทำการอ่านหรือเขียนหน่วยความจำที่แชร์นั้น เมื่อทำงานเสร็จแล้วโปรเซสนั้นจะเซ็ตกลับเป็น 0 เหมือนเดิมโดยใช้คำสั่ง MOVEเมื่อโ ) รเซสต้องการเข้า Critical Region จะเรียก enter_region แล้วเริ่มการทำงานโดยการก็อปปี้ค่าเดิมของ LOCK ไปเก็บที่รีจีสเตอร์ แล้วเซ็ตค่าLOCK เป็น 1 จากนั้นจะเปรียบเทียบค่าเดิมกับ0ถ้าไม่ไช่ค่า 0 ค่า LOCK ที่เซ้ตเป็น1จะกลับไปเริ่มต้นที่จุดเริ่มต้นเพื่อตรวจสอบอีกครั้ง จนกระทั่งเป็น 0 ( เมื่อโปรเซสที่กำลังอยู่ใน Critical Regionเสร็จเรียบร้อยแล้ว ) และรูทีนย่อยจะรีเทิร์นด้วยการเซ็ตค่า LOCK ส่วนการเคลียค่าก็เป็นเรื่องง่ายแค่การเก็บค่า 0 ไว้ใน LOCK เท่านั้น&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-1580537281183009993?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/1580537281183009993/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=1580537281183009993' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/1580537281183009993'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/1580537281183009993'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/13-mutual-exclusion-with-busy-waiting.html' title='1.3 Mutual Exclusion with busy waiting'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-2121181208533164662</id><published>2007-12-06T21:21:00.000-08:00</published><updated>2007-12-06T21:21:05.226-08:00</updated><title type='text'>1.4 Sleep and Wakeup</title><content type='html'>ทั่งวิธีการของปีเตอร์สันและการใช้คำสั่ง TSL เป็นวิธีการที่ถถูกต้องกว่าวคือ ถ้าโปรเซสใดต้องการเข้า Critical Region แต่ยังไม่ได้รับอนุญาตก็วนรอบรอจนกว่าโปรเซสที่กำลังอยู่ใน Critical Region เสร็จออกมา และได้รับอนุญาตไม่เพียงการเสียเวลารอจากวิธีการทั้งสองเท่านั้น ในบางครั้งสิทธิ์ในการเข้าใช้งานมีไม่เท่ากัน จะทำให้โปรเซสที่มีสิทธิ์สูงกว่าได้เข้าก่อน ถึงเเม้โปรเซสที่มาก่อนแต่มีสิทธิ์ต่ำกว่าก็ยังเข้าไม่ได้ แทนที่จะหยุดรอตามวิธีทั้งสองทำไมไม่ใช้วิธีการบล็อกแทนการหยุดรอเพื่อเข้า Critical Region ซึ่งวิธีการบล็อกที่ง่ายที่สุดก็คือ Sleep and WakeupSleep เป็น system call เพื่อบล็อกให้โปรเซสหยุดทำงาน (เนื่องจากเข้าCriticalRegion ไม่ได้ ) จนกว่าจะมีโปรเซสอื่นมาปลุกให้ทำงานต่อ ส่วน Rakeup เป็น system call ที่ปลุกให้โปรเซสทำงานต่อ เนื่องจาก Sleep และ Wakeup จะทำงานสลับกันดังนั้นจึงต้องมีการใช้พารามิเตอร์และแอ็ดเดรสของหน่วยความจำที่สัมพันธ์กัน&lt;br /&gt;- The porducer-consumer problem&lt;br /&gt;ตัวอย่าง sleep and wakeup ที่ง่ายที่สุดคือปัญญา Producer-Consumer ทั้ง 2 ส่วนจะใช้บัฟเฟอร์ที่แชร์ร่วมกันในขนาดที่คงที่ ปกติแล้วเราสามารถประยุกต์ให้มี Producer ได้ m ตัว และ Consumer ได้ n ตัว แต่ในที่นี้เราจะกำหนดให้มี Producer และ Consumer ได้เพียงอย่างละ 1 ตัวเท่านั้น โดยการทำงาจะเป็นดังนี้&lt;br /&gt;- Producer     จะทำหน้ที่ผลิตข้อมูลแล้วนำไปเก็บไว้ในบัเฟอร์แล้วจะหยุดการผลิตเมื่อบัฟเฟอร์เต็ม&lt;br /&gt;- Consumer     จะนำข้อมูลจากบัฟเฟอร์ไปใช้ ( ต้องมีอย่างน้อย 1 ชิ้น ) แล้วจะหยุดเมื่อบัฟเฟอร์ว่าง&lt;br /&gt;อาจกล่าวในลักษณะ Sleep and Wakeup ได้ดังนี้&lt;br /&gt;- Producer  จะ Sleep ตัวเองเมื่อบัฟเฟอร์เต็ม และจะ Wakeup ให้ Consumer นำข้อมูลไปใช้เมื่อมีข้อมูลอย่างน้อย 1 ชุดในบัฟเฟอร์&lt;br /&gt;- Consumer  จะ Sleep ตัวอย่างเมื่อบยัฟเฟอร์ว่างและจะมี Wakeup ให้ Producer ผลิตข้อมูลเมื่อนำข้อมูลอกไปใช้ 1 ชุดหรือมากกว่า&lt;br /&gt;โดยที่&lt;br /&gt;- Sleep จะเป็นการเปลี่ยนสถานะจาก Running blocked&lt;br /&gt;- Wakeup จะเป็นการเปลี่ยนสถานะจาก Blocked Ready ในการกำหนดขนาดของบัฟเฟอร์จะต้องมีการกำหนดตัวแปร count เพื่อกำหนดว่าบัฟเฟอร์สามารถเก็บข้อมูลได้กี่ชุด สามารถว่ากำหนดเป็น n แสดงว่บัฟเฟอร์นั้นสามารถเก็บข้อมูลได้ n ชุดโดยก่อนที่ producerจะผลิตก็จะทำการตรวจสอบก่อนว่าตัวแปร count มีค่าเป็น n หรือไม่ ถ้าเป็น n อยู่ก็จะ sleep ตัวเอง แต่ถ้ายังน้อยกว่าnก็จะผลิตข้อมูลเพิ่มในบัฟเฟอร็ต่อไปแล้วเพิ่มค่าตัวแปร count ส่วนโค๊ดใน consumer ก็มีลักษณะคล้ายกับproducer กล่าวคือเมื่อ consumer จะนำข้อมูลไปใช้จะมีตรวจสอบว่า count เป็น 0 หรือไม่ถ้าเป็น0(แสดงบัฟเฟอร์ ว่าง ) ก็จะ sleep ตัวเอบง แต่ถ้าไม่ไช่ 0 ก็จะเริ่มนำข้อมูลออกใช้ แล้ลดค่าตัวแปรcountนอกจากนี้ในแต่ละโปรเซสจะตรวจสอบโปรเซสอื่นด้วย ถ้าโปรเซสอื่น sleep อยู่ก็จะ wakeup ให้ด้วยสำหรับโค๊ดของ producer และ consumer จะมีดังนี้&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-2121181208533164662?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/2121181208533164662/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=2121181208533164662' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2121181208533164662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/2121181208533164662'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/14-sleep-and-wakeup.html' title='1.4 Sleep and Wakeup'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-5024055593363426737</id><published>2007-12-06T21:20:00.000-08:00</published><updated>2007-12-06T21:20:18.476-08:00</updated><title type='text'>1.5 Semaphore</title><content type='html'>ในปี ค.ศ. 1965 ไดจก์สตรา ได้แนะนำให้ใช้ตัวแปรจำนวนเต็มเพื่อนับจำนวน Wakeup ที่อาจจะนำไปใช้ในอนาคตเรียกว่า Semaphoreปฏิบัติการ Down ใน semaphore จะตรวจสอบค่าตัวแปร ถ้าค่ามากกว่า 0 จะลดค่าแล้วดำเนินต่อไป แต่ถ้าค่าเป็น 0 โปรเซสจะเป็น sleep ตัวเองโดยไม่จำเป็นต้องให้ปฏิบัติการ down เสร็จสมบูรณ์ก่อน การตรวจสอบเปลี่ยนแปลงจนนำไปสู่การ sleep เป็นขั้นตอนเดียวโดยอัตโนมัติ จึงอาจเรียกได้ว่าเป็นindivisibleautomatic actionเป็นการยืนยันได้ว่า ปฏิบัติการของ semaphore เพียงปฏิบัติการเดียว ที่เริ่มต้น ทำให้โปรเซสอื่นไม่สามารถแอ็กเซส semaphore ได้จนกว่าปฏิบัติการจะเสร็จสมบูรณ์หรือมีการบล็อกความเป็นอัตโนมัตินี้เองเป็นสิ่งสำคัญในการแก้ปํญหาซินโคไนซ์ และหลีกเลี่ยงการ race condition คำสั่งปฏิบัติการ down อาจเขียนได้เป็น&lt;br /&gt;&lt;br /&gt;IF Semaphore &gt;0&lt;br /&gt;THEN&lt;br /&gt;Decrement Semaphore&lt;br /&gt;( ลดค่า Semaphore ลง 1 )&lt;br /&gt;ELSE&lt;br /&gt;Wait UNTIL semaphore=0&lt;br /&gt;Sleep()&lt;br /&gt;สำหรับปฏิบัติการ Up จะเพิ่มค่าของ แอ๊ดเดรส ถ้ามีโปรเซสตั้งแต่1โปรเซสขึ้นไป sleep บน semaphore นั้นจะไม่สามาสรถทำให้ปฏิบัติการ down ก่อนหน้านั้นเสร็จสิ้นลงไปได้แต่ระบบจะปิดบางตัวและยอมให้เสร็จสิ้นได้ทำให้เกิดปฏิบัติการ up บน semaphore ที่สุ่มนั้นทำให้เพิ่มค่า semaphore ขึ้น อีก 1 ทำให้ wakeup ได้ และเช่นเดียวกับปฏิบัติการ downที่ในระหว่างดำเนินตามปฏิบัติการทั้งสอง จะไม่สามารถอินเทอร์รัพต์นอกจากจะใช้ disable interrupt เข้าช่วย เช่น ในโพรซีเดอร์ down อาจเขียนได้เป็น&lt;br /&gt;{Disable interrupt&lt;br /&gt;If semaphore&gt;0then&lt;br /&gt;Decrement semaphore&lt;br /&gt;Continue&lt;br /&gt;Else&lt;br /&gt;Wait until semaphore&lt;br /&gt;Able interrupt}&lt;br /&gt;สำหรับระบบที่มีซีพียูมากกว่า1ตัวจะใช้ Disable interrupt ไม่ได้ อาจจะต้องใช้ STL เข้าช่วยได้ ส่วนรูปแบบของ semaphore จากไดจก์สตรา เสนอในตอนต้นนั้น เขาใช้ p,v เนื่องจากเป็นภาษาดัทช์pคือการตรวจสอบ ส่วน v คือการค่า เราใช้แทน down และ up แทน p และ v ตามลำดับ&lt;br /&gt;นอกจากปัญหา Producer-consumer ที่ผ่านมาเราสามารถใช้ semnaphore ช่วยแก้ไขได้ ตามรูป #define N 100 /* จำนวนสล็อตในบัฟเฟอร์*//&lt;br /&gt;Tyopedef int semaphore; /* กำหนหดประเภทตัวแปรเป็น int*/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-5024055593363426737?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/5024055593363426737/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=5024055593363426737' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/5024055593363426737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/5024055593363426737'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/15-semaphore.html' title='1.5 Semaphore'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-6005983761032687326</id><published>2007-12-06T21:19:00.001-08:00</published><updated>2007-12-06T21:19:47.221-08:00</updated><title type='text'>1.6 Event Counter</title><content type='html'>Event Counter เป็นตัวแปร integer ที่นับจำนวนเหตุการณ์ที่เกิดขึ้น โดยมีค่าเริ่มต้นอยู่ที่ 0 แล้วจะเพิ่ม&lt;br /&gt;ขึ้นเรื่อย ๆ โดย Event Counter จะมีปฏิบัติการที่เกี่ยวข้อง 2 ปฏิบัติการ ดังนี้&lt;br /&gt;•  Read (E) จะเป็นปฏิบัติการสำหรับการอ่านค่า&lt;br /&gt;•  Advance (E) จะเป็นปฏิบัติการที่ทำหน้าที่เพิ่มค่าขึ้นอีก 1 (E=E+1)&lt;br /&gt;•  Await (E.V) จะเป็นปฏิบัติการที่ทำให้เกิด Sleep&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-6005983761032687326?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/6005983761032687326/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=6005983761032687326' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6005983761032687326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6005983761032687326'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/16-event-counter.html' title='1.6 Event Counter'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-6929263234783505292</id><published>2007-12-06T21:19:00.000-08:00</published><updated>2007-12-06T21:19:16.532-08:00</updated><title type='text'>1.7 Mutex Mutex</title><content type='html'>เป็น Semaphore อย่างง่ายที่นำมาใช้ในการจัดการ Mutual Exclusion กับรีซอร์สที่แชร์ได้อย่างมีประสิทธิภาพ โดยเฉพาะกับ Thread ( ที่เราจะศึกษาเพิ่มเติมในหัวข้อต่อไป)โดยMutexเป็นตัวแปรที่มีสภาวะได้2สภาวะคือ unlocked และ locked ที่ใช้เพียง 1 บิตที่แสดงสภาวะของมัน แต่ในทางปฏิบัติเราใช้ integer&lt;br /&gt;ในสภาวะ unlocked จะใช้ 0 ส่วนสภาวะ locked จะใช้เลขอื่น เราจะใช้ 2 โปรซีเดอร์&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-6929263234783505292?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/6929263234783505292/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=6929263234783505292' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6929263234783505292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/6929263234783505292'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/17-mutex-mutex.html' title='1.7 Mutex Mutex'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-4709213096140888460</id><published>2007-12-06T21:18:00.000-08:00</published><updated>2007-12-06T21:39:48.376-08:00</updated><title type='text'>1.8 Monitor</title><content type='html'>การใช้ Semaphore ดูเป็นเรื่องง่าย แต่ถ้าดูให้ลึกซึ้งพิจารณาดังนี้ สมมุติมีปฏิบัติการ Down 2 ปฏิบัติการในโค้ดของ Producer ที่เรียงย้อนกลับดังนั้น Mutex จะลดค่าก่อน emptyแทนที่จะลดค่าภายหลังถ้าบัฟเฟอร์เต็มแล้ว Producer จะถูกบล็อก โดย Mutex จะมีค่าเป็น 0 สภาวะเช่นนี้เรียกว่า “ Consumer “ ที่กล่าวมาเป็นการเตือนให้ระมัดระวังการใช้ Semaphore เพื่อป้องกันข้อผิดพลาดที่จะเกิดขึ้น&lt;br /&gt;&lt;a name="zzz"&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-4709213096140888460?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/4709213096140888460/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=4709213096140888460' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4709213096140888460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/4709213096140888460'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/16-monitor.html' title='1.8 Monitor'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-981803281592391235.post-455779037754088469</id><published>2007-12-06T21:17:00.000-08:00</published><updated>2007-12-06T21:17:27.577-08:00</updated><title type='text'>ปัญหาการทำงานของโปรเซส</title><content type='html'>ปัญหาการทำงานของโปรเซส&lt;br /&gt;ปัญหาที่เกิดขึ้นกับระบบปฏิบัติการเป็นปัญหาที่หน้าสนใจและถกเถียงกันอย่างกว้างขวางตลอดจนมีการวิเคราะห์โดยการใช้วิธีการด้านซินโครไนต์จะกล่าวถึง3ปัญหาดังนี้&lt;br /&gt;1.TheDiningPhilosophersProblemปัญหาแรกนี้ไดจก์สตราได้เสนอไว้โดยสมมุติว่ามีนักปราชญ์5ท่านนั่งรอบโต๊ะกลมเพื่อทานอาหารที่วางตรงหน้าในการทานอาหารนักปราชญ์แต่ละท่านต้องใช้ตะเกียบทั้ง2ข้าง ที่วางอยู่ซ้ายมือและขวามือ เมื่อทานเสร็จในรอบนั้นจะต้องวางตะเกียบลงเพื่อเปิดโอกาสให้ทานอื่นได้ทานอาหารบ้างจะเกิดDeadlock เมื่อทั้ง5ท่านหยิบตะเกียบท่านละ1ข้างพร้อมกันสมมุติว่าทุกท่านหยิบตะเกียบข้างซ้ายมือพร้อมกันทุกท่านจะต้อรอตะเกียบข้างขวาว่างจึงจะทานอาหารได้&lt;br /&gt;2. The Readers-Writers Problem&lt;br /&gt;ปัญหาการทานอาหารของนักปราชญ์มีประโยชน์มากสำหรับการเป็นโมเดลของโปรเซสที่ช่วยแก้ปัญหาการใช้รีซอร์สที่แชร์กันอยู่อย่างจำกัดยังมีปัญหาอีกอย่างคือ Readers-Writers Problem เป็นปัญหาเกี่ยวข้องกับระบบคอมพิวเตอร์ที่มีกลุ่มข้อมูลใช้งานร่วมกันซึ่งมีโปรเซสอยู่ 2 ประเภทคือ อ่านข้อมูลร่วมและที่บัญทึกหรือเขียนข้อมูล&lt;br /&gt;-The Sleeping Barber Problem ปัญหาที่ 3 เป็นปัญหาที่เกิดในร้านตัดผมที่มีช่างตัดผม 1 คน เก้าอี้ตัดผม 1 ตัวและมีเก้าอี้ที่นั่งรอคิวอีกจำนวน 1 ถ้าไม่มีลูกค้าช่างตัดผมจะนอนพักผ่อนบนเก้าอี้ตัดผมเทื่อลูกค้าเข้ามาในร้านจะปลุกช่างตัดผมเข้ามาตัดผมถ้ามีลุกค้าเดินมาเข้าร้านเพิ่มอีกก็จะนี่งรอหรือไม่ก็ออกจากร้านไป&lt;br /&gt;การแก้ปัญหาจะใช้ 3 Semaphore ดังนี้&lt;br /&gt;- Customers ที่นับจำนวนลูกค้า&lt;br /&gt;- Barbers ที่นับจำนวนช่างตัดผม 0 หรือ 1&lt;br /&gt;-Mutex ที่ใช้สำหรับ Mutual Exclusion &lt;a name="xxx"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Threads&lt;br /&gt;Threads&lt;br /&gt;1. โปรเซสที่กล่าวผ่านมาเป็นการเอ็กซิคิวต์โปรแกรมในลักษณะมีการควบคุมเพียง 1 Threads ( แต่ละโปรเซสจะประกอบด้วย Threads เพียง Threads เดียวเท่านั้น ) แต่ในระบบปฏิบัติการสมัยใหม่ในแต่ละ โปรเซสสามารถมีได้หลาย Threads อาจจะกล่าวได้ว่า Threads ก็คือส่วนประกอบย่อยโปรเซสนั่นเอง จนบางครั้งอาจเรียก Threads ว่า “ Lightweigh Process “ ( LWP ) ในรูป 2.19 ( ก ) คุณจะเห็น โปรเซส 3 โปรเซส แต่ละโปรเซสจะมีแอ็ดเดรสเป็นของตนเอง และควบคุมเพียง 3 Threads โดยใช้แอ็ดเรสเดียวกันอยู่&lt;br /&gt;2.รูป 2.19 ( ก ) 3 โปรเซสแต่ละโปรเซสมี 1 Threads ( ข ) 1 โปรเซสที่มี 3 Thread ( Mos : P82 )&lt;br /&gt;Threads เป็นหน่วยพื้นฐานของการจัดสรรการใช้ประโยชน์ของซีพียู ที่ประกอบด้วย&lt;br /&gt;- หมายเลข Threads ( Threads ID ) เป็นหมายเลข ฮ ในโปรเซส&lt;br /&gt;- ตัวนับ เพื่อติดตามให้ทราบคำสั่งต่อไปที่จะเอ็กซิคิวต์&lt;br /&gt;- ชุดของรีจิสเตอร์ เพื่อเก็บค่าตัวแปรที่ทำงานอยู่&lt;br /&gt;-  ชุดของรีจิสเตอร์ เพื่อเก็บค่าตัวแปรที่ทำงานอยู่&lt;br /&gt;- สแต็ก ( Stack ) เพื่อเก็บประวัติการเอ็กซิคิวต์&lt;br /&gt;ภายในโปรเซสที่ประกอบด้วย thread จะมีการโค้ด , ข้อมูล และรีซอร์ส เช่น ไฟส์ , อุปกรณ์ต่าง ๆ เป็นต้น โปรเซสดั้งเดิม ( ที่เรียกว่า heavyweight ) จะทำงานได้ลายงานในเวลาเดียวกันซอฟต์แวร์ปัจจุบันที่รันกับเครื่องพีซีสมัยใหม่มีการออกแบบให้เป็น multithreded โดยแยกออกเป็นโปรเซสที่ควบคุมหลาย ๆ thread เช่น โปรแกรมเว็บบราวเซอร์ที่มี thread หนึ่งในการแสดงรูปภาพหรือข้อความในขณะที่อีก thread หนึ่งกำลังดึงข้อมูลจากเน๊ตเวิรค หรืออย่างในโปรแกรมเวิรด์โปรเซสเซอร์ที่มีหลาย thread โดยที่ thread หนึ่งกำลังแสดงภาพกราฟฟิก ในขณะที่ therad ที่สองกำลังรอรับคำสั่งจากคีย์บอร์ดจากผู้ใช้ ในขณะที่ Thread ที่สามกำลังตรวจสอบคำสะกดและ ไวยากรณ์ในลักษณะแบ็คกราว เป็นต้น&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/981803281592391235-455779037754088469?l=juy12.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://juy12.blogspot.com/feeds/455779037754088469/comments/default' title='ส่งความคิดเห็น'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=981803281592391235&amp;postID=455779037754088469' title='0 ความคิดเห็น'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/455779037754088469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/981803281592391235/posts/default/455779037754088469'/><link rel='alternate' type='text/html' href='http://juy12.blogspot.com/2007/12/blog-post.html' title='ปัญหาการทำงานของโปรเซส'/><author><name>ผู้ก่อการดี</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
