Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Linux ½ø³Ìµ÷¶È»úÖÆ

ÓÅÏÈȨֻÊǵ÷¶ÈËã·¨¿¼ÂǵÄÒ»¸ö·½Ãæ
½ø³Ìµ÷¶ÈÒÀ¾Ý
µ÷¶È³ÌÐòÔËÐÐʱ£¬ÒªÔÚËùÓпÉÔËÐÐ״̬µÄ½ø³ÌÖÐÑ¡Ôñ×îÖµµÃÔËÐеĽø³ÌͶÈëÔËÐС£Ñ¡Ôñ½ø³ÌµÄÒÀ¾ÝÊÇʲôÄØ£¿ÔÚÿ¸ö½ø³ÌµÄtask_struct½á¹¹ÖÐÓÐÒÔÏÂËÄÏpolicy¡¢priority¡¢counter¡¢rt_priority¡£ÕâËÄÏîÊÇÑ¡Ôñ½ø³ÌµÄÒÀ¾Ý¡£ÆäÖУ¬policyÊǽø³ÌµÄµ÷¶È²ßÂÔ£¬ÓÃÀ´Çø·Öʵʱ½ø³ÌºÍÆÕͨ½ø³Ì£¬ÊµÊ±½ø³ÌÓÅÏÈÓÚÆÕͨ½ø³ÌÔËÐУ»priorityÊǽø³Ì(°üÀ¨ÊµÊ±ºÍÆÕͨ)µÄ¾²Ì¬ÓÅÏȼ¶£»counterÊǽø³ÌÊ£ÓàµÄʱ¼äƬ£¬ËüµÄÆðʼֵ¾ÍÊÇpriorityµÄÖµ£»ÓÉÓÚcounterÔÚºóÃæ¼ÆËãÒ»¸ö´¦ÓÚ¿ÉÔËÐÐ״̬µÄ½ø³ÌÖµµÃÔËÐеij̶ÈgoodnessʱÆðÖØÒª×÷Óã¬Òò´Ë£¬counterÒ²¿ÉÒÔ¿´×÷Êǽø³ÌµÄ¶¯Ì¬ÓÅÏȼ¶¡£rt_priorityÊÇʵʱ½ø³ÌÌØÓеģ¬ÓÃÓÚʵʱ½ø³Ì¼äµÄÑ¡Ôñ¡£
LinuxÓú¯Êýgoodness()À´ºâÁ¿Ò»¸ö´¦ÓÚ¿ÉÔËÐÐ״̬µÄ½ø³ÌÖµµÃÔËÐеij̶ȡ£¸Ãº¯Êý×ÛºÏÁËÒÔÉÏÌáµ½µÄËÄÏ»¹½áºÏÁËһЩÆäËûµÄÒòËØ£¬¸øÿ¸ö´¦ÓÚ¿ÉÔËÐÐ״̬µÄ½ø³Ì¸³ÓèÒ»¸öȨֵ(weight)£¬µ÷¶È³ÌÐòÒÔÕâ¸öȨֵ×÷ΪѡÔñ½ø³ÌµÄΨһÒÀ¾Ý¡£¹ØÓÚgoodness()µÄÇé¿öÔÚºóÃ潫»áÏêϸ·ÖÎö¡£
½ø³Ìµ÷¶È²ßÂÔ
µ÷¶È³ÌÐòÔËÐÐʱ,ÒªÔÚËùÓд¦ÓÚ¿ÉÔËÐÐ״̬µÄ½ø³ÌÖ®ÖÐÑ¡Ôñ×îÖµµÃÔËÐеĽø³ÌͶÈëÔËÐС£Ñ¡Ôñ½ø³ÌµÄÒÀ¾ÝÊÇʲôÄØ?ÔÚÿ¸ö½ø³ÌµÄtask_struct ½á¹¹ÖÐÓÐÕâôËÄÏ
policy, priority , counter, rt_priority
ÕâËÄÏî¾ÍÊǵ÷¶È³ÌÐòÑ¡Ôñ½ø³ÌµÄÒÀ¾Ý.ÆäÖÐ,policyÊǽø³ÌµÄµ÷¶È²ßÂÔ,ÓÃÀ´Çø·ÖÁ½ÖÖ½ø³Ì-ʵʱºÍÆÕͨ£»priorityÊǽø³Ì(ʵʱºÍÆÕͨ)µÄÓÅÏȼ¶£»counter Êǽø³ÌÊ£ÓàµÄʱ¼äƬ,ËüµÄ´óСÍêÈ«ÓÉpriority¾ö¶¨;rt_priorityÊÇʵʱÓÅÏȼ¶,ÕâÊÇʵʱ½ø³ÌËùÌØÓеģ¬ÓÃÓÚʵʱ½ø³Ì¼äµÄÑ¡Ôñ¡£
Ê×ÏÈ£¬Linux ¸ù¾Ýpolicy´ÓÕûÌåÉÏÇø·Öʵʱ½ø³ÌºÍÆÕͨ½ø³Ì£¬ÒòΪʵʱ½ø³ÌºÍÆÕͨ½ø³Ì¶Èµ÷¶ÈÊDz»Í¬µÄ£¬ËüÃÇÁ½ÕßÖ®¼ä£¬ÊµÊ±½ø³ÌÓ¦¸ÃÏÈÓÚÆÕͨ½ø³Ì¶øÔËÐУ¬È»ºó£¬¶ÔÓÚͬһÀàÐ͵IJ»Í¬½ø³Ì£¬²ÉÓò»Í¬µÄ±ê×¼À´Ñ¡Ôñ½ø³Ì£º
¶ÔÓÚÆÕͨ½ø³Ì£¬Linux²ÉÓö¯Ì¬ÓÅÏȵ÷¶È£¬Ñ¡Ôñ½ø³ÌµÄÒÀ¾Ý¾ÍÊǽø³ÌcounterµÄ´óС¡£½ø³Ì´´½¨Ê±£¬ÓÅÏȼ¶priority±»¸³Ò»¸ö³õÖµ£¬Ò»°ãΪ0¡«70Ö®¼äµÄÊý×Ö£¬Õâ¸öÊý×ÖͬʱҲÊǼÆÊýÆ÷counterµÄ³õÖµ£¬¾ÍÊÇ˵½ø³Ì´´½¨Ê±Á½ÕßÊÇÏàµÈµÄ¡£×ÖÃæÉÏ¿´£¬priorityÊÇ"ÓÅÏȼ¶"¡¢counterÊÇ"¼ÆÊýÆ÷"µÄÒâ˼£¬È»¶øʵ¼ÊÉÏ£¬ËüÃDZí´ïµÄÊÇͬһ¸öÒâ˼-½ø³ÌµÄ"ʱ¼äƬ"¡£Priority´ú±í·ÖÅä¸ø¸Ã½ø³ÌµÄʱ¼äƬ£¬counter±íʾ¸Ã½ø³ÌÊ£ÓàµÄʱ¼äƬ¡£ÔÚ½ø³ÌÔËÐйý³ÌÖУ¬counter²»¶Ï¼õÉÙ£¬¶øpriority±£³Ö²»±ä£¬ÒÔ±ãÔÚcounter±äΪ0µÄʱºò£¨¸Ã½ø³ÌÓÃÍêÁËËù·ÖÅäµÄʱ¼äƬ£©


Ïà¹ØÎĵµ£º

LinuxϽâѹѹËõ¼°´ò°üÃüÁî´óÈ«


LinuxϽâѹѹËõ¼°´ò°üÃüÁî´óÈ«
[ÈÕÆÚ£º2008-11-04]
À´Ô´£º  ×÷Õߣºjenen
 
———————————————
.tar
½â°ü£ºtar xvf FileName.tar
´ò°ü£ºtar cvf FileName.tar DirName
£¨×¢£ºtarÊÇ´ò°ü£¬²»ÊÇѹËõ£¡£©
&mdas ......

linuxÃüÁîÔ´ÂëµÄ²é¿´

ÔÚƽ³£µÄ×÷ÒµÖУ¬ÓÐʱºòÀÏʦÈÃ×Ô¼ºÊµÏÖÖîÈçcatµÈÀàµÄ³ÌÐò£¬ÓÐʱºò½ÐÓÃshellʵÏÖ£¬ÓÐʱºòÓÃcʵÏÖ£¬µ«ÊÇÎÒ¾­³£Ò»µãÍ·Ð÷¶¼Ã»ÓУ¬²»¹ýÎÒÏëµ½linux¿ªÔ´µÄ£¬ÃüÁî´úÂë¿ÉÒÔÄÃÀ´²Î¿¼Ï°¢£¬ËùÒÔÎÒ¾ÍÏë¿´¿´linuxÃüÁîµÄÔ´´úÂ룬ÓÚÊǾͿªÊ¼Á˰ڶɹ·¹·µÄËÑË÷¹ý³Ì¡£´Ó½á¹ûÀ´¿´£¬ÓÐÁ½ÖÖÇé¿ö£¬Ò»ÖÖÊǸøÓèrpmµÄ°üµÄÐÎʽ£»ÁíÒ»ÖÖÊÇ»ùÓÚdeb°üµÄÐ ......

linuxÁ´½ÓÎļþ

 Á´½ÓÎļþÓеãÀàËÆÓÚWindows µÄËùν¿ì½Ý·½Ê½£¬µ«²¢²»ÍêÈ«Ò»Ñù¡£Á´½ÓÓÐÁ½ÖÖ·½Ê½£¬ÈíÁ´½ÓºÍÓ²Á´½Ó¡£
¡¡¡¡ÈíÁ´½ÓÎļþ
¡¡¡¡ÈíÁ´½ÓÓֽзûºÅÁ´½Ó£¬Õâ¸öÎļþ°üº¬ÁËÁíÒ»¸öÎļþµÄ·¾¶Ãû¡£¿ÉÒÔÊÇÈÎÒâÎļþ»òĿ¼£¬¿ÉÒÔÁ´½Ó²»Í¬ÎļþϵͳµÄÎļþ¡£Á´½ÓÎļþÉõÖÁ¿ÉÒÔÁ´½Ó²»´æÔÚµÄÎļþ£¬Õâ¾Í²úÉúÒ»°ã³Æ֮Ϊ"¶ÏÁ´"µÄÎÊÌâ(»òÔ»“ÏÖ ......

linux api±Ê¼Ç£¨5£©£ºỊ̈߳¨Èý£©

ÕâÀï¼ÌÐøÉÏһƪ¹ØÓÚÏ̺߳¯ÊýµÄ½éÉÜ£º
int pthread_detach (pthread_t thread_handle);
 
Õâ¸öº¯ÊýµÄ×÷ÓÃÊÇÈÃthread_handleÖ¸ÏòµÄÄ¿±êÏß³ÌÔÚÖÐÖ¹µÄʱºòÇåÀí×Ô¼ºÓµÓеÄÊý¾Ý¡£ÔÚÕâ¸öº¯Êýµ÷ÓÃÖ®ºó£¬
²»ÄÜÔÙ¶Ôthread_handleʹÓÃpthread_join¡£
ÏÔ¶øÒ×¼ûµÄÊÇ£¬Èç¹ûÎÒÃÇûÓжÔд´½¨µÄÏ̵߳÷ÓÃpthread_detach£¬Õâ¸öÏß ......

linux api±Ê¼Ç£¨6£©£ºỊ̈߳¨ËÄ£© Ïß³Ì˽ÓÐÊý¾Ý

±¾ÎĽ«ÃèÊöÏ̵߳ÄÒ»¸ö±È½ÏÖØÒªµÄÒ»·½Ã棺Ïß³Ì˽ÓÐÊý¾Ý£¬ÈçÏ´úÂ룺
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
pthread_key_t kKey = 0;
void * ThreadProc(void* arg)
{
char* a = (char*)(arg);
sleep(2);
pthread_setspecific(kKey, a);
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ