6 ÐÔÄÜ |
±¾ÕµÄËùÓÐÐÔÄܲÎÊýÊÇÔÚSPARCstation 1+(Sun 4/65)ÉÏ»ñµÃµÄ£¬´Ë¹¤×÷Õ¾ÊÇÒ»¸ö25Mhz SPARC¹¤×÷ƽ̨¡£Í¨¹ýʹÓÃÄÚǶµÄ΢Ã뼶ʵʱ¶¨Ê±Æ÷À´×ö²âÁ¿¡£²ÎÊý·´Ó³Á˷ǵ÷½ÚµÄÔÐÍϵͳ¡£
µÚÒ»¸ö²âÁ¿ÊÇÏßË÷´´½¨Ê±¼ä¡£Ëü²âÁ¿´´½¨Ò»¸öÏßË÷µÄ¿ªÏúʱ¼ä£¬´ËÏßË÷ʹÓÃÓÉÏßË÷°ü»º³åµÄȱʡ¶ÑÕ»¡£Ëù²âÁ¿µÄʱ¼ä½ö°üÀ¨Êµ¼ÊµÄ´´½¨Ê±¼ä£¬Ëü²»°üÀ¨³õʼÉÏÏÂÎÄÇл»ÏßË÷µÄʱ¼ä¡£Í¼5ÏÔʾ½á¹û¡£ratioÁиø³öÁËÄÇÒ»ÐеĴ´½¨Ê±¼äÓëÇ°Ò»Ðд´½¨Ê±¼äµÄ±ÈÀý¡£
½øÐÐÁË´´½¨°ó¶¨ºÍ·Ç°ó¶¨ÏßË÷µÄ²âÁ¿¡£°ó¶¨ÏßË÷µÄ´´½¨Éæ¼°Á˵÷ÓúËÐÄ£¬ÒÔ´´½¨ÔËÐÐËüµÄLWP¡£²»ÓúËÐĵĽéÈ룬¾Í¿ÉÒÔ×ö·Ç°ó¶¨ÏßË÷µÄ´´½¨¡£
µÚ¶þ¸ö²âÁ¿ÊÇÏßË÷ͬ²½Ê±¼ä¡£Ëü²âÁ¿Á½¸öÏßË÷ͨ¹ýÁ½¸öͬ²½±äÁ¿±Ë´Ëͬ²½µÄ¿ªÏúʱ¼ä£¬ÈçÏÂÃæËùʾ£º
sema_t s1, s2;
thread1()
{
...
start_timer();
sema_v(&s1);
sema_p(&s2);
t = end_timer();
...
}
thread2()
{
...
sema_p(&s2);
sema_v(&s1);
...
}
ͼ6ËùÌá³öµÄ²ÎÊýÊÇÉÏÃæµÄ²âÁ¿³ýÒÔ2µÄ½á¹û£¬ÒòΪʵ¼ÊÉÏÉæ¼°ÁËÁ½¸öͬ²½¡£ratioÁиø³öÁËÄÇÒ»ÐеÄͬ²½Ê±¼äÓëÇ°Ò»ÐÐͬ²½Ê±¼äµÄ±ÈÀý¡£´
µÚÒ»¸ö²âÁ¿ÊÇÒ»¸ö¼òµ¥µÄÀý³Ì£¬Ëü×ösetjmp()ºÍlongjmp()µ½Ëü×Ô¼º¡£ËüµÄÌá³ö£¬×÷ΪÏßË÷Çл»Ê±¼äµÄ»ù×¼¡£ÏÂÁ½¸ö²âÁ¿ÊǷǰ󶨺Ͱó¶¨ÏßË÷ÔÚ½ø³ÌÄÚͬ²½¡£×îºóµÄ²âÁ¿ÊÇÁ½¸ö²»Í¬½ø³ÌµÄÏßË÷ͨ¹ý¹²ÏíÄÚ´æµÄÎļþÀ´Í¬²½¡£
Copyright: NPACT |