ÉîÈëdz³öLinuxÉ豸Çý¶¯Ö®×èÈûÓë·Ç×èÈû
×¢: ¸ÃϵÁÐÎÄÕÂתÔØ×Ôarm+linux chinaunix²©¿ÍȦȦÖ÷Ö®²©¿Í——http://blog.chinaunix.net/u/22630 /article_54997.html ΪÁËÊʺÏÎҵıàÒë»·¾³£¬Ô´´úÂëÓиĶ¯£¬µ«ÊÇÏàÐÅÎÒ¸ü¸ÄºóµÄ´úÂë¸ü¼ÓÊʺÏÏÖÔÚ´ó¶àÊý¶ÁÕßµÄpc»·¾³¡£
×èÈû²Ù×÷ÊÇÖ¸£¬ÔÚÖ´ÐÐÉ豸²Ù×÷ʱ£¬Èô²»ÄÜ»ñµÃ×ÊÔ´£¬Ôò½ø³Ì¹ÒÆðÖ±µ½Âú×ã¿É²Ù×÷µÄÌõ¼þÔÙ½øÐвÙ×÷¡£±»¹ÒÆðµÄ½ø³Ì½øÈësleep״̬£¬±»´Óµ÷¶ÈÆ÷µÄÔËÐжÓÁÐÒÆ×ߣ¬Ö±µ½µÈ´ýµÄÌõ¼þ±»Âú×ã¡£·Ç×èÈû²Ù×÷µÄ½ø³ÌÔÚ²»ÄܽøÐÐÉ豸²Ù×÷ʱ£¬²¢²»¹ÒÆð¡£±ÈÈçsocketÀïÃæµÄread£¬Èç¹û¿Í»§¶Ë²»·¢ËÍÊý¾Ý£¬ÄÇô·þÎñ¶Ë¾ÍÒªÒ»Ö±µÈÏÂÈ¥¡£
ÔÚLinuxÇý¶¯³ÌÐòÖУ¬ÎÒÃÇ¿ÉÒÔʹÓõȴý¶ÓÁУ¨wait queue£©À´ÊµÏÖ×èÈû²Ù×÷¡£wait queueºÜÔç¾Í×÷Ϊһ¸ö»ù±¾µÄ¹¦Äܵ¥Î»³öÏÖÔÚLinuxÄÚºËÀïÁË£¬ËüÒÔ¶ÓÁÐΪ»ù´¡Êý¾Ý½á¹¹£¬Óë½ø³Ìµ÷¶È»úÖƽôÃܽáºÏ£¬Äܹ»ÓÃÓÚʵÏÖºËÐĵÄÒ첽ʼþ֪ͨ»úÖÆ¡£µÈ´ý¶ÓÁпÉÒÔÓÃÀ´Í¬²½¶Ôϵͳ×ÊÔ´µÄ·ÃÎÊ£¬ÉϽÚÖÐËù½²ÊöLinuxÐźÅÁ¿ÔÚÄÚºËÖÐÒ²ÊÇÓɵȴý¶ÓÁÐÀ´ÊµÏֵġ£
waitµÄAPI£º
wait_event(queue, condition)
wait_event_interruptible(queue, condition)
wait_event_timeout(queue, condition, timeout)
wait_event_interruptible_timeout(queue, condition, timeout)
µÈ´ýcondition±äΪtrue£¬·ñÔòһֱ˯Ãß
condition¿ÉÒÔÔÚÈκεط½±»¸Ä±ä£¬µ«¸Ä±äʱÐëwake_up µÈ´ý¶ÓÁÐwqÀïÃæµÄprocess¡£
»½ÐѺ¯Êý£º
void wake_up(wait_queue_head_t *queue); //»½ÐÑËùÓÐ
void wake_up_interruptible(wait_queue_head_t *queue); //»½ÐÑinterruptible
ÏÂÃæÎÒÃÇÖØж¨ÒåÉ豸"globalvar"£¬Ëü¿ÉÒÔ±»¶à¸ö½ø³Ì´ò¿ª£¬µ«ÊÇÿ´ÎÖ»Óе±Ò»¸ö½ø³ÌдÈëÁËÒ»¸öÊý¾ÝÖ®ºó±¾½ø³Ì»òÆäËü½ø³Ì²Å¿ÉÒÔ¶ÁÈ¡¸ÃÊý¾Ý£¬·ñÔòÒ»Ö±×èÈû¡£
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/wait.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
MODULE_LICENSE("GPL");
#define MAJOR_NUM 250 //Ö÷É豸ºÅ
static ssize_t globalvar_read(struct file *, char *, size_t, loff_t*);
static ssize_t globalvar_write(struct file *, const char *, size_t, loff_t*);
static int globalvar_open(struct inode *,struct file *);
Ïà¹ØÎĵµ£º
su
suÃüÁîÊÇ×î»ù±¾µÄÃüÁîÖ®Ò»£¬³£ÓÃÓÚ²»Í¬Óû§¼äÇл»¡£ÀýÈ磬Èç¹ûµÇ¼Ϊ user1£¬ÒªÇл»Îªuser2£¬Ö»ÒªÓÃÈçÏÂÃüÁ
$su user2
È»ºóϵͳÌáʾÊäÈëuser2¿ÚÁÊäÈëÕýÈ·µÄ¿ÚÁîÖ®ºó¾Í¿ÉÒÔÇл»µ½user2¡£Íê³ÉÖ®ºó¾Í¿ÉÒÔÓÃexitÃüÁî·µ»Øµ½user1¡£
suÃüÁîµÄ³£¼ûÓ÷¨ÊDZä³É¸ùÓû§»ò³¬¼¶Óû§¡£Èç¹û·¢³ö²»´øÓû§ÃûµÄsuÃüÁî £¬Ôòϵ ......
Õâ´Îתµ½Á˺½¿ÕµÄÒ»¸öÏîÄ¿£¬ÐèÒªÔÚLinuxÏÂÓÃC×ö¿ª·¢¡£°æ±¾¹ÜÀí²ÉÓÃSVN£¬´Ó×òÌìÏÂÎ翪ʼÎҾͿªÊ¼ÁË°²×°£¬ÕæµÄÊÇÍ´¿àµÄ¹ý³Ì¡£ÏÖÔÚµ¹ÊÇ°²×°ºÃÁË£¬µ«ÊÇÅäÖÃÃüÁûÓÐÕÆÎÕ¡£
Èç¹ûÓÐȨÏÞ´ÓÍøÉÏÖ±½Ó¸üÐÂÈí¼þ£¬ÎÒ²»±Øÿ´Î¶¼È¥ÕÒÔ´Âë°ü£¬È ......
vi filename :´ò¿ª»òн¨Îļþ£¬²¢½«¹â±êÖÃÓÚµÚÒ»ÐÐÊ×
¡¡¡¡vi +n filename £º´ò¿ªÎļþ£¬²¢½«¹â±êÖÃÓÚµÚnÐÐÊ×
¡¡¡¡vi + filename £º´ò¿ªÎļþ£¬²¢½«¹â±êÖÃÓÚ×îºóÒ»ÐÐÊ×
¡¡¡¡vi +/pattern filename£º´ò¿ªÎļþ£¬²¢½«¹â±êÖÃÓÚµÚÒ»¸öÓëpatternÆ¥ÅäµÄ´®´¦
¡¡¡¡vi -r filename £ºÔÚÉÏ´ÎÕýÓÃvi±à¼Ê±·¢Éúϵͳ±ÀÀ££¬»Ö¸´filename
......
scull µÄMakefile
Makefile½Å±¾ÈçÏÂËùʾ¡£
--------------------------------------------------------------------------------
KERNEL_MAKE := -C /home/zhoumin/hi3511/Hi3511_VSSDK_V1.1.2.1/pub/kbuild-LESS_REL
PWD := $(shell pwd ......