spinlock ÓëlinuxÄں˵÷¶ÈµÄ¹Øϵ
¹ØÓÚ×ÔÐýËøÓ÷¨½éÉܵÄÎÄÕ£¬ÒѾÓкܶ࣬µ«ÓÐЩϸ½ÚµÄµØ·½µãµÄ»¹²»¹»Í¸¡£ÎÒÕâÀï¾Í°ÑÎÒ¸öÈËÈÏΪ´ó¼ÒÈÝÒ×ÓÐÒÉÎʵĵط½ÄóöÀ´ÌÖÂÛһϡ£
Ò»¡¢×ÔÐýËø£¨spinlock£©¼ò½é
×ÔÐýËøÔÚͬһʱ¿ÌÖ»Äܱ»×î¶àÒ»¸öÄÚºËÈÎÎñ³ÖÓУ¬ËùÒÔÒ»¸öʱ¿ÌÖ»ÓÐÒ»¸öÏß³ÌÔÊÐí´æÔÚÓÚÁÙ½çÇøÖС£Õâµã¿ÉÒÔÓ¦ÓÃÔڶദÀí»úÆ÷¡¢»òÔËÐÐÔÚµ¥´¦ÀíÆ÷ÉϵÄÇÀռʽÄÚºË
ÖÐÐèÒªµÄËø¶¨·þÎñ¡£
¶þ¡¢ÐźÅÁ¿¼ò½é
ÕâÀïÒ²½éÉÜÏÂÐźÅÁ¿µÄ¸ÅÄÒòΪËüµÄÓ÷¨ºÍ×ÔÐýËøÓÐÏàËƵĵط½¡£
LinuxÖеÄÐźÅÁ¿ÊÇÒ»ÖÖ˯ÃßËø¡£Èç¹ûÓÐÒ»¸öÈÎÎñÊÔͼ»ñµÃÒ»¸öÒѱ»³ÖÓеÄÐźÅÁ¿Ê±£¬ÐźÅÁ¿»á½«ÆäÍÆÈëµÈ´ý¶ÓÁУ¬È»ºóÈÃÆä˯Ãß¡£Õâʱ´¦ÀíÆ÷»ñµÃ×ÔÓÉÈ¥Ö´ÐÐ
ÆäËü´úÂë¡£µ±³ÖÓÐÐźÅÁ¿µÄ½ø³Ì½«ÐźÅÁ¿Êͷźó£¬Ôڵȴý¶ÓÁÐÖеÄÒ»¸öÈÎÎñ½«±»»½ÐÑ£¬´Ó¶ø±ã¿ÉÒÔ»ñµÃÕâ¸öÐźÅÁ¿¡£
Èý¡¢×ÔÐýËøºÍÐźÅÁ¿¶Ô±È
ÔںܶàµØ·½×ÔÐýËøºÍÐźÅÁ¿¿ÉÒÔÑ¡ÔñÈκÎÒ»¸öʹÓ㬵«Ò²ÓÐһЩµØ·½Ö»ÄÜÑ¡ÔñijһÖÖ¡£ÏÂÃæ¶Ô±ÈһЩÁ½ÕßµÄÓ÷¨¡£
±í1-1×ÔÐýËøºÍÐźÅÁ¿¶Ô±È
Ó¦Óó¡ºÏ
ÐźÅÁ¿or
×ÔÐýËø
µÍ¿ªÏú¼ÓËø£¨ÁÙ½çÇøÖ´ÐÐʱ¼ä½Ï
¿ì£©
ÓÅÏÈÑ¡Ôñ×ÔÐýËø
µÍ¿ªÏú¼ÓËø£¨ÁÙ½çÇøÖ´ÐÐʱ¼ä½Ï
³¤£©
ÓÅÏÈÑ¡ÔñÐźÅÁ¿
ÁÙ½çÇø¿ÉÄÜ°üº¬ÒýÆð˯ÃߵĴúÂë
²»ÄÜÑ¡×ÔÐýËø£¬¿ÉÒÔÑ¡ÔñÐÅ
ºÅÁ¿
ÁÙ½çÇøλÓڷǽø³ÌÉÏÏÂÎÄʱ£¬´Ëʱ²»ÄÜ˯Ãß
ÓÅÏÈÑ¡Ôñ×ÔÐýËø
£¬¼´Ê¹Ñ¡ÔñÐÅ
ºÅÁ¿Ò²Ö»ÄÜÓÃdown_trylock
·Ç×èÈûµÄ·½Ê½
ËÄ¡¢×ÔÐýËøÓëlinuxÄں˽ø³Ìµ÷¶È¹Øϵ
ÎÒÃÇÌÖÂÛϱí1-1ÖеĵÚ3ÖÖÇé¿ö£¨ÆäËü¼¸ÖÖÇé¿ö±È½ÏºÃÀí½â£©£¬Èç¹ûÁÙ½çÇø¿ÉÄÜ°üº¬ÒýÆð˯ÃߵĴúÂëÔò²»ÄÜʹÓÃ×ÔÐýËø£¬·ñÔò¿ÉÄÜÒýÆðËÀËø¡£
ÄÇôΪʲôÐźÅÁ¿±£»¤µÄ´úÂë¿ÉÒÔ˯Ã߶ø×ÔÐýËø¾Í²»ÄÜÄØ£¿
ÏÈ¿´ÏÂ×ÔÐýËøµÄʵÏÖ·½·¨°É£¬×ÔÐýËøµÄ»ù±¾ÐÎʽÈçÏ£º
spin_lock(&mr_lock);
//ÁÙ½çÇø
spin_unlock(&mr_lock);
¸ú×ÙÒ»ÏÂspin_lock(&mr_lock)µÄʵÏÖ
#define spin_lock(lock) _spin_lock(lock)
#define _spin_lock(lock) __LOCK(lock)
#define __LOCK(lock) \
do { preempt_disable(); __acquire(lock);
(void)(lock); } while (0)
×¢Òâµ½“preempt_disable()”£¬Õâ¸öµ÷ÓõŦÄÜÊÇ“¹ØÇÀÕ¼”£¨ÔÚspin_unlockÖлáÖØпªÆôÇÀÕ¼¹¦ÄÜ£©¡£´ÓÖпÉÒÔ¿´³ö£¬Ê¹ÓÃ×ÔÐý
Ëø±£»¤µÄÇøÓòÊǹ¤×÷ÔÚ·ÇÇÀÕ¼µÄ״̬£»¼´Ê¹»ñÈ¡²»µ½Ëø£¬ÔÚ“×ÔÐý”״̬ҲÊǽûÖ¹ÇÀÕ¼µÄ¡£Á˽⵽Õ⣬ÎÒÏëÔÛÃÇÓ¦¸ÃÄܹ»Àí½âΪºÎ×ÔÐýËø±£»¤µÄ´úÂë²»ÄÜ˯ÃßÁË¡£ÊÔ
Ïëһϣ¬Èç¹
Ïà¹ØÎĵµ£º
ÔÚ32λƽ̨ÉϱàÒ붯̬¿âûÓÐɶÎÊÌ⣬Äõ½x86_64λƽ̨ÉϱàÒëʱ³öÏÖÁËÎÊÌâ¡£
relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
ÕÕ×ÅÌáʾ±àÒë´úÂëµÄʱºò¼ÓÈë -fPICÑ¡Ïî¾Íok.
......
ÔÚfedoraϽâѹ.debÎļþ(û°²×°dpkg):
ar p filename.deb data.tar.gz | tar zxvf -
ÆäËüѹËõÎļþµÄ½âѹ
#tar xv file.a
#uncompress file.Z
#gunzip file.gz
#bunzip2 file.bz2
#tar xvZf file.tar.Z
#compress -dc file.tar.Z | tar xvf -
#tar xvzf file.tar.gz
#gzip -dc file.tar.gz | tar ......
±¾ÎÄÏêϸ½éÉÜÈçºÎ±àдһ¸öÏÔ¿¨µÄÇý¶¯³ÌÐò¡£
framebuffer
deviceÔÚÄÚºËÀïÃæ×÷ΪÏÔ¿¨Çý¶¯Ä£ÐÍ£¬Ðí¶àº¯ÊýºÍÊý¾Ý½á¹¹¶¼ÊÇÌض¨£¬ÕýÊÇÕâЩÌض¨µÄ¶«Î÷ΪÎÒÃǵıà³ÌÌṩÁË·½±ã¡£
Òª¿ª·¢frame buffer
deviceÇý¶¯£¬ÄãÓ¦¸ÃÔĶÁSource\Source\Documentation\fbÏÂÃæµÄ˵Ã÷Îļþ£¬Èý¸öÖØÒªÎļþ00-
INDEX£¬framebuffer.txt£¬internal ......
linux²¢²»ÊÇʵʱ²Ù×÷ϵͳ£¬°ÑÏÂÃæµÄ´úÂëÔËÐÐÒ»±é¾ÍÄܹ»Àí½âÁË£¬´úÂëÓкÜÏêϸµÄ×¢ÊÍ¡£
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
void * thr_fun(void *arg)
{
int policy, ret;
str ......
Ò»¡¢Linux device driver µÄ¸ÅÄî
ϵͳµ÷ÓÃÊDzÙ×÷ϵͳÄں˺ÍÓ¦ÓóÌÐòÖ®¼äµÄ½Ó¿Ú£¬É豸Çý¶¯³ÌÐòÊDzÙ×÷ϵͳÄں˺ͻúÆ÷Ó²¼þÖ®¼äµÄ½Ó¿Ú¡£É豸Çý¶¯³ÌÐòΪӦÓóÌÐòÆÁ±ÎÁËÓ²¼þµÄϸ½Ú£¬ÕâÑùÔÚÓ¦ÓóÌ
Ðò¿´À´£¬Ó²¼þÉ豸ֻÊÇÒ»¸öÉ豸Îļþ£¬Ó¦ÓóÌÐò¿ÉÒÔÏó²Ù×÷ÆÕͨÎļþÒ»Ñù¶ÔÓ²¼þÉ豸½øÐвÙ×÷¡£Éè±¸Ç ......