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

Linux Device DriversÔĶÁ±Ê¼Ç

Linux Device Drivers, 3rd Edition
2.3.1. User Space and Kernel Space
Äں˿ռäºÍÓû§¿Õ¼ä
Unix transfers execution from user space to kernel space whenever an application issues a system call or is suspended by a hardware interrupt. Kernel code executing a system call is working in the context of a process—it operates on behalf of the calling process and is able to access data in the process's address space. Code that handles interrupts, on the other hand, is asynchronous with respect to processes and is not related to any particular process.
ÕâÊǺܹؼüµÄ¶ÎÂ䣺
Unix¿ÉÒÔͨ¹ýϵͳµ÷ÓúÍÓ²¼þÖжÏʵÏÖ´ÓÓû§¿Õ¼äµ½Äں˿ռäµÄÇл»¡£¶ÔÓÚϵͳµ÷Óã¬Äں˴úÂëÔËÐÐÓÚµ÷Óýø³ÌµÄÉÏÏÂÎÄÖУ¬Äں˴úÂë¿ÉÒÔ·ÃÎʵ÷Óýø³ÌµÄÊý¾Ý¡£¶ÔÓÚÓ²¼þÖжϣ¬Äں˴úÂëÔËÐÐÓÚÖжÏÉÏÏÂÎÄ£¬¶ÀÁ¢ÓÚµ±Ç°±»´ò¶ÏµÄ½ø³Ì£¬ËùÒÔ´Ëʱ²»ÄÜ·ÃÎʱ»Öжϵĵ±Ç°½ø³Ì¿Õ¼äµÄÊý¾Ý¡£
´ÓÓû§¿Õ¼äÇл»µ½Äں˿ռäʱҪʹÓÃÄں˿ռä¶ÑÕ»,linuxÄں˿ռä¶ÑÕ»<8k, дÄں˳ÌÐòÒªÏ൱עÒâÕ»µÄʹÓá£
µ±ÏµÍ³´ÓÄں˿ռ䷵»Ø»òÕß´ÓÖжÏÉÏÏÂÎÄÖзµ»ØÓû§¿Õ¼äʱ£¬Èç¹ûÓÐÖØÐµ÷¶ÈÐèÇó£¬ÏµÍ³»á½øÐÐÖØÐµ÷¶È£¬¼´Óû§ÇÀÕ¼¡£
ϵͳ´¦ÓÚÖжÏÉÏÏÂÎÄ»òÕß½ø³Ì³ÖÓÐ×ÔÐýËøÊ±²»ÔÊÐíÄÚºËÇÀÕ¼¡£
ÄÚºËÇÀÕ¼Ò»°ã·¢ÉúÔÚ£¬
    1 µ±ÏµÍ³ÔÚÄں˿ռäÖ´ÐÐʱ£¬±»Ä³¸öÖжϴò¶Ï£¬µ±´ÓÕâ¸öÖжϷµ»ØÄں˿ռäʱ¡£
    2 Äں˿ռäÊÍ·Å×ÔÐýËøÊ±¡£
3.7. read and write
unsigned long copy_to_user(void _ _user *to,
const void *from,
unsigned long count);
unsigned long copy_from_user(void *to,
const void _ _user *from,
unsigned long count);
Although these functions behave like normal memcpy functions, a little extra care must be used when accessing user space from kernel code. The user pages being addressed might not be currently present in memory, and the virtual memory subsystem can put the process to sleep while the page is being transferred into place. This happens, for example, when the page must be retrieved from swap space.
Äں˿ռäºÍÓû§¿Õ¼ä¿½±´Êý¾Ýʱ


Ïà¹ØÎĵµ£º

Linux »ã±àÓïÑÔ¿ª·¢Ö¸ÄÏ


developerWorks Öйú
  >  
Linux
  >
Linux »ã±àÓïÑÔ¿ª·¢Ö¸ÄÏ
ÎĵµÑ¡Ïî
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td>< ......

LINUXÍøÂç±à³Ì

      ÍøÂç±à³ÌºÍÆäËû±à³Ì×î´óµÄÇø±ð¾ÍÊÇ£ºÍøÂç±à³ÌÓÉÁ½²¿·Ö×é³É£¬¿Í»§¶ËºÍ·þÎñÆ÷¶Ë¡£ÏÈÆô¶¯·þÎñÆ÷¶Ë¡¢µÈ´ý¿Í»§¶ËµÄ³ÌÐòÔËÐв¢½¨Á¢Á¬½Ó£»Ò»°ãÀ´Ëµ£¬ÊÇ·þÎñÆ÷¶ËµÄ³ÌÐòÔÚÒ»¸ö¶Ë¿ÚÉϼàÌý£¬µÈ´ýÓÐÒ»¸ö¿Í»§¶ËµÄ³ÌÐò·¢À´ÇëÇó¡£
      ÍøÂç±à³Ì»¹ÒªÒýÈëÒ»¸ö¸ÅÄЭÒé¡£ÔÚÍøÂç ......

Linux϶àÏß³Ì(pthread)±à³ÌʵÀý

LinuxϵͳϵĶàÏß³Ì×ñÑ­POSIXÏ߳̽ӿڣ¬³ÆÎª pthread¡£±àдLinuxϵĶàÏ̳߳ÌÐò£¬ÐèҪʹÓÃÍ·Îļþpthread.h£¬Á¬½ÓʱÐèҪʹÓÿâlibpthread.a¡£Ë³±ã˵һÏ£¬Linux ÏÂpthreadµÄʵÏÖÊÇͨ¹ýϵͳµ÷ÓÃclone£¨£©À´ÊµÏֵġ£clone£¨£©ÊÇ LinuxËùÌØÓеÄϵͳµ÷Óã¬ËüµÄʹÓ÷½Ê½ÀàËÆfork£¬¹ØÓÚclone£¨£©µÄÏêϸÇé¿ö£¬ÓÐÐËȤµÄ¶ÁÕß¿ÉÒÔÈ¥²é ......

LinuxÏÂÀûÓÃÌõ¼þ±äÁ¿ÊµÏÖ¶ÁÐ´Ëø

Ê×ÏȽéÉÜÏÂpthread_cond_t¡£ ÔÚLinuxϳÆÖ®Îª×´Ì¬±äÁ¿£¬ÓëÖ®Ïà¹ØµÄÓÐÏÂÃæ¼¸¸öAPI:
    int pthread_cond_init (pthread_cond_t *COND,pthread_condattr_t *cond_ATTR);
    int pthread_cond_signal (pthread_cond_t *COND);
    int pthread_cond_broadcast (pthread_con ......

Linuxƽ̨ÏÂѧϰ·ÖÀà

(1) Linux »ù´¡£º°üÀ¨Linux °æ±¾£¬°²×°£¬ÃüÁîµÈ֪ʶµÄÕÆÎÕ¡£
(2) Linux ϵͳ¿ª·¢£ºÖ÷ÒªÊÇÇý¶¯½Ó¿Ú£¬ÄÚºËÅäÖý»²æ±àÒ룬ÄÚºËÈ¡µã£¬busybox£¬µÈµÈ·½Ãæ¡£
(3)Linux ǶÈëʽӦÓÿª·¢£ºÇ¶ÈëʽLINUXÓ¦ÓóÌÐò¿ª·¢ÊÇÔÚ²Ù×÷ϵͳÉÏ×ö¿ª·¢£¬ÀàËÆWindowsϵÄVC»òJAVA¿ª·¢¡£
(4)Linux ÍøÂç±à³Ì£ººÍÔÚwindowϵÄsocket±à³ÌÀàËÆ£¬°üÀ¨Ì×½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ