亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? fifos.c

?? rtai-3.1-test3的源代碼(Real-Time Application Interface )
?? C
?? 第 1 頁 / 共 4 頁
字號:
/** * @ingroup fifos * @ingroup fifos_ipc * @ingroup fifos_sem * @file * * Implementation of the @ref fifos "RTAI FIFO module". * * @author Paolo Mantegazza * * @note Copyright &copy; 1999-2003 Paolo Mantegazza <mantegazza@aero.polimi.it> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* ACKNOWLEDGEMENTS: - nice proc file contributed by Steve Papacharalambous (stevep@zentropix.com);- added proc handler info contributed by Rich Walker (rw@shadow.org.uk)- 11-19-2001, Truxton Fulton (trux@truxton.com) fixed a race in mbx_get.- 10-23-2003 added atomic send contributed by Jan Kiszka   (kiszka@rts.uni-hannover.de) and expanded it to rtf_get_if.- 12-10-2003 a fix of rtf_resize odds contributed by Abramo Bagnara  (abramo.bagnara@tin.it).*//** * @defgroup fifos RTAI FIFO module * * See @ref fifos_overview "the general overview of RTAI fifos". *//** * @ingroup fifos * @defgroup fifos_ipc Inter-process communications. * * RTAI FIFO communication functions. * * RTAI fifos maintain full compatibility with those available in NMT_RTLinux * while adding many other useful services that avoid the clumsiness of * Unix/Linux calls. So if you need portability you should bent yourself to the * use of select for timing out IO operations, while if you have not to satisfy * such constraints use the available simpler, and more direct, RTAI fifos * specific services. * * In the table below the standard Unix/Linux services in user space are * enclosed in []. See standard Linux man pages if you want to use them, they * need not be explained here. * * <CENTER><TABLE> * <TR><TD> Called from RT task </TD><TD> Called from Linux process </TD></TR> * <TR><TD> #rtf_create         </TD><TD> #rtf_open_sized           <BR> *                                         [open]                   </TD></TR> * <TR><TD> #rtf_destroy        </TD><TD>  [close]                  </TD></TR> * <TR><TD> #rtf_reset          </TD><TD> #rtf_reset                </TD></TR> * <TR><TD> #rtf_resize         </TD><TD> #rtf_resize               </TD></TR> * <TR><TD> #rtf_get            </TD><TD>  [read]                   <BR> *                                        #rtf_read_timed           <BR> *                                        #rtf_read_all_at_once     </TD></TR> * <TR><TD> #rtf_put            </TD><TD>  [write]                  <BR> *                                        #rtf_write_timed          </TD></TR> * <TR><TD> #rtf_create_handler </TD><TD>                           </TD></TR> * <TR><TD>                     </TD><TD> #rtf_suspend_timed        </TD></TR> * <TR><TD>                     </TD><TD> #rtf_set_async_sig        </TD></TR> * </TABLE></CENTER> * * In Linux, fifos have to be created by : * @verbatim $ mknod /dev/rtf<x> c 150 <x> @endverbatim * where \<x\> is the minor device number, from 0 to 63; thus on the Linux side * RTL fifos can be used as standard character devices. As it was said above to * use standard IO operations on such devices there is no need to explain * anything, go directly to Linux man pages. RTAI fifos specific services * available in kernel and user space are instead explained here. * * What is important to remember is that in the user space side you address * fifos through the file descriptor you get at fifo device opening while in * kernel space you directly address them by their minor number. So you will * mate the @a fd you get in user space by using * @verbatim open(/dev/rtfxx,...) @endverbatim * to the integer @p xx you will use in kernel space. * * @note RTAI fifos should be used just with applications that use only real * time interrupt handlers, so that no RTAI scheduler is installed, or if you * need compatibility with NMT RTL.  If you are working with any RTAI scheduler * already installed you are strongly invited to think about avoiding them, use * LXRT instead. * * It is far better and flexible, and if you really like it the fifos way * mailboxes are a one to one, more effective, substitute.   After all RTAI * fifos are implemented on top of them. *//** * @ingroup fifos * @defgroup fifos_sem Semaphores. * * RTAI FIFO semaphore functions. * * Fifos have an embedded synchronization capability, however using them only * for such a purpose can be clumsy. So RTAI fifos have binary semaphores for * that purpose. Note that, as for put and get fifos functions, only nonblocking * functions are available in kernel space. *  * <CENTER><TABLE> * <TR><TD> Called from RT task </TD><TD> Called from Linux process </TD></TR> * <TR><TD> #rtf_sem_init       </TD><TD> #rtf_sem_init             </TD></TR> * <TR><TD> #rtf_sem_post       </TD><TD> #rtf_sem_post             </TD></TR> * <TR><TD> #rtf_sem_trywait    </TD><TD> #rtf_sem_wait             <BR> *                                        #rtf_sem_trywait          <BR> *                                        #rtf_sem_timed_wait       </TD></TR> * <TR><TD> #rtf_sem_destroy    </TD><TD> #rtf_sem_destroy          </TD></TR> * </TABLE></CENTER> * * To add a bit of confusion (J), with respect to RTAI schedulers semaphore * functions, fifos semaphore functions names follow the POSIX mnemonics. * * It should be noted that semaphores are associated to a fifo for * identification purposes. So it is once more important to remember is that * in the user space side you address fifos through the file descriptor you get * at fifo device opening while in kernel space you directly address them by * their minor number.   So you will mate the fd  you get in user space by * @verbatim open(/dev/rtfxx,) @endverbatim to the integer @p xx youll use in * kernel space. */#include <linux/module.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/version.h>#include <linux/errno.h>#include <linux/mm.h>#include <linux/vmalloc.h>#include <linux/poll.h>#include <linux/termios.h>#include <linux/tty_driver.h>#include <linux/console.h>#include <linux/config.h>#include <linux/slab.h>#include <linux/devfs_fs_kernel.h>#include <linux/stat.h>#include <linux/proc_fs.h>#include <rtai_fifos.h>#include <rtai_trace.h>#include <rtai_proc_fs.h>#include <rtai_sched.h>#include <rtai_lxrt.h>MODULE_LICENSE("GPL");/* these are copied from <rt/rt_compat.h> */#define rtf_save_flags_and_cli(x)	do{x=rt_spin_lock_irqsave(&rtf_lock);}while(0)#define rtf_restore_flags(x)		rt_spin_unlock_irqrestore((x),&rtf_lock)#define rtf_spin_lock_irqsave(x,y)	do{x=rt_spin_lock_irqsave(&(y));}while(0)#define rtf_spin_unlock_irqrestore(x,y)	rt_spin_unlock_irqrestore((x),&(y))#define rtf_request_srq(x)		rt_request_srq(0, (x), 0)#define rtf_free_srq(x)			rt_free_srq((x))#define rtf_pend_srq(x)			rt_pend_linux_srq((x))#ifdef CONFIG_PROC_FSstatic int rtai_proc_fifo_register(void);static void rtai_proc_fifo_unregister(void);#endiftypedef struct lx_queue {	struct lx_queue *prev;	struct lx_queue *next;	struct lx_task_struct *task;} F_QUEUE;typedef struct lx_semaphore {	int free;	int qtype;	F_QUEUE queue;} F_SEM;typedef struct lx_task_struct {	int blocked;	int priority;	F_QUEUE queue;	struct task_struct *task;} LX_TASK;typedef struct lx_mailbox {	int size;   // size of the entire buffer	int fbyte;  // head	int lbyte;  // tail	int avbs;   // bytes available in the buffer	int frbs;   // free bytes in the buffer	char *bufadr;	F_SEM sndsem, rcvsem;	struct task_struct *waiting_task;	spinlock_t buflock;} F_MBX;typedef struct rt_fifo_struct {	F_MBX mbx;		// MUST BE THE FIRST!	int opncnt;	int malloc_type;	int pol_asyn_pended;	wait_queue_head_t pollq;	struct fasync_struct *asynq;	int (*handler)(unsigned int arg);	F_SEM sem;	char name[RTF_NAMELEN+1];} FIFO;static int fifo_srq, async_sig;static spinlock_t rtf_lock = SPIN_LOCK_UNLOCKED;static spinlock_t rtf_name_lock = SPIN_LOCK_UNLOCKED;#define MAX_FIFOS 64//static FIFO fifo[MAX_FIFOS] = {{{0}}};static FIFO *fifo;#define MAXREQS 64	// KEEP IT A POWER OF 2!!!static struct { int in, out; struct task_struct *task[MAXREQS]; } taskq;static struct { int in, out; FIFO *fifo[MAXREQS]; } pol_asyn_q;static RT_TASK *rt_base_linux_task;static int do_nothing(unsigned int arg) { return 0; }static inline void enqueue_blocked(LX_TASK *task, F_QUEUE *queue, int qtype, int priority){	F_QUEUE *q;	task->blocked = 1;	q = queue;	if (!qtype) {		while ((q = q->next) != queue && (q->task)->priority >= priority);	}	q->prev = (task->queue.prev = q->prev)->next  = &(task->queue);	task->queue.next = q;}static inline void dequeue_blocked(LX_TASK *task){	task->blocked = 0;	(task->queue.prev)->next = task->queue.next;	(task->queue.next)->prev = task->queue.prev;}static inline void mbx_sem_signal(F_SEM *sem, FIFO *fifop){	unsigned long flags;	LX_TASK *task;	rtf_save_flags_and_cli(flags);	if ((task = (sem->queue.next)->task)) {		dequeue_blocked(task);		taskq.task[taskq.in] = task->task;		taskq.in = (taskq.in + 1) & (MAXREQS - 1);		rtf_pend_srq(fifo_srq);	} else {		sem->free = 1;		if (fifop && !(fifop->pol_asyn_pended) &&		    (((F_MBX *)fifop)->avbs || ((F_MBX *)fifop)->frbs) &&		    (waitqueue_active(&fifop->pollq) || fifop->asynq)) {			fifop->pol_asyn_pended = 1;			pol_asyn_q.fifo[pol_asyn_q.in] = fifop;			pol_asyn_q.in = (pol_asyn_q.in + 1) & (MAXREQS - 1);			rtf_pend_srq(fifo_srq);		}	}	rtf_restore_flags(flags);	return;}static inline void mbx_signal(F_MBX *mbx){	unsigned long flags;	struct task_struct *task;	rtf_save_flags_and_cli(flags);	if ((task = mbx->waiting_task)) {		mbx->waiting_task = 0;		taskq.task[taskq.in] = task;		taskq.in = (taskq.in + 1) & (MAXREQS - 1);		rtf_pend_srq(fifo_srq);	}	rtf_restore_flags(flags);	return;}static inline int mbx_sem_wait_if(F_SEM *sem){	unsigned long flags;	rtf_save_flags_and_cli(flags);	if (sem->free) {		sem->free = 0;		rtf_restore_flags(flags);		return 1;	}	rtf_restore_flags(flags);	return 0;}static inline int mbx_sem_wait(F_SEM *sem){	unsigned long flags;	LX_TASK task;	int ret;	ret = 0;	rtf_save_flags_and_cli(flags);	if (!sem->free) {		task.queue.task = &task;		task.priority = current->rt_priority;		enqueue_blocked(&task, &sem->queue, sem->qtype, task.priority);		task.task = current;		rtf_restore_flags(flags);		current->state = TASK_INTERRUPTIBLE;		schedule();		if (signal_pending(current)) {			ret = -ERESTARTSYS;		}		rtf_save_flags_and_cli(flags);		if (task.blocked) { 			dequeue_blocked(&task);			if (!(sem->queue.next)->task) {				sem->free = 1;			}			rtf_restore_flags(flags);			if (!ret) {				ret = -1;			}		}	} else {		sem->free = 0;	}	rtf_restore_flags(flags);	return ret;}static inline int mbx_wait(F_MBX *mbx, int *fravbs){	unsigned long flags;	rtf_save_flags_and_cli(flags);	if (!(*fravbs)) {		mbx->waiting_task = current;		current->state = TASK_INTERRUPTIBLE;		rtf_restore_flags(flags);		schedule();		if (signal_pending(current)) {			return -ERESTARTSYS;		}		rtf_save_flags_and_cli(flags);		if (mbx->waiting_task == current) {			mbx->waiting_task = 0;			rtf_restore_flags(flags);			return -1;		}	}	rtf_restore_flags(flags);	return 0;}static inline int mbx_sem_wait_timed(F_SEM *sem, int delay){	unsigned long flags;	LX_TASK task;	rtf_save_flags_and_cli(flags);	if (!sem->free) {		task.queue.task = &task;		task.priority = current->rt_priority;		enqueue_blocked(&task, &sem->queue, sem->qtype, task.priority);		task.task = current;		rtf_restore_flags(flags);		current->state = TASK_INTERRUPTIBLE;		schedule_timeout(delay);		if (signal_pending(current)) {			return -ERESTARTSYS;		}		rtf_save_flags_and_cli(flags);		if (task.blocked) { 			dequeue_blocked(&task);			if (!((sem->queue.next)->task)) {				sem->free = 1;			}			rtf_restore_flags(flags);			return -1;		}	} else {		sem->free = 0;	}	rtf_restore_flags(flags);	return 0;}static inline int mbx_wait_timed(F_MBX *mbx, int *fravbs, int delay){	unsigned long flags;	rtf_save_flags_and_cli(flags);	if (!(*fravbs)) {		mbx->waiting_task = current;		rtf_restore_flags(flags);		current->state = TASK_INTERRUPTIBLE;		schedule_timeout(delay);		if (signal_pending(current)) {			return -ERESTARTSYS;		}		rtf_save_flags_and_cli(flags);		if (mbx->waiting_task == current) {;			mbx->waiting_task = 0;			rtf_restore_flags(flags);			return -1;		}	}	rtf_restore_flags(flags);	return 0;}#define MOD_SIZE(indx) ((indx) < mbx->size ? (indx) : (indx) - mbx->size)static inline int mbx_put(F_MBX *mbx, char **msg, int msg_size, int lnx){	unsigned long flags;	int tocpy;	while (msg_size > 0 && mbx->frbs) {		if ((tocpy = mbx->size - mbx->lbyte) > msg_size) {			tocpy = msg_size;		}		if (tocpy > mbx->frbs) {			tocpy = mbx->frbs;		}		if (lnx) {			copy_from_user(mbx->bufadr + mbx->lbyte, *msg, tocpy);		} else {			memcpy(mbx->bufadr + mbx->lbyte, *msg, tocpy);		}		rtf_spin_lock_irqsave(flags, mbx->buflock);		mbx->lbyte = MOD_SIZE(mbx->lbyte + tocpy);		mbx->frbs -= tocpy;		mbx->avbs += tocpy;		rtf_spin_unlock_irqrestore(flags, mbx->buflock);		msg_size -= tocpy;		*msg     += tocpy;	}	return msg_size;}static inline int mbx_ovrwr_put(F_MBX *mbx, char **msg, int msg_size, int lnx){	unsigned long flags;	int tocpy,n;	if ((n = msg_size - mbx->size) > 0) {		*msg += n;		msg_size -= n;	}			while (msg_size > 0) {		if (mbx->frbs) {				if ((tocpy = mbx->size - mbx->lbyte) > msg_size) {				tocpy = msg_size;			}			if (tocpy > mbx->frbs) {				tocpy = mbx->frbs;			}			if (lnx) {				copy_from_user(mbx->bufadr + mbx->lbyte, *msg, tocpy);			} else {				memcpy(mbx->bufadr + mbx->lbyte, *msg, tocpy);			}			rtf_spin_lock_irqsave(flags, mbx->buflock);			mbx->frbs -= tocpy;			mbx->avbs += tocpy;			rtf_spin_unlock_irqrestore(flags, mbx->buflock);			msg_size -= tocpy;			*msg     += tocpy;			mbx->lbyte = MOD_SIZE(mbx->lbyte + tocpy);		}	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日本在线视频| 日韩精品亚洲一区| 亚洲自拍偷拍网站| 国产乱码精品一区二区三| 一本大道综合伊人精品热热| 国产欧美一区二区三区网站| 日本午夜一区二区| 欧美在线免费视屏| 亚洲精品视频在线观看免费| 国产传媒久久文化传媒| 日韩欧美成人激情| 午夜视频一区二区三区| 99re8在线精品视频免费播放| 精品人在线二区三区| 日本视频在线一区| 欧美日韩五月天| 亚洲午夜电影在线| 91免费观看视频| 亚洲欧洲色图综合| 岛国av在线一区| 日本一区二区免费在线| 国产一区二区三区四区在线观看| 欧美一级片免费看| 久久99在线观看| 日韩精品中文字幕一区二区三区| 日韩成人一区二区| 91.麻豆视频| 日韩av中文字幕一区二区| 欧美午夜片在线看| 午夜视频一区二区| 欧美一区二区视频在线观看| 丝袜a∨在线一区二区三区不卡| 欧美亚洲自拍偷拍| 视频一区欧美精品| 日韩精品一区二区三区四区| 激情综合五月天| 欧美国产欧美综合| 91小宝寻花一区二区三区| 中文字幕日韩精品一区| 在线观看一区不卡| 免费人成网站在线观看欧美高清| 欧美一区二区三区免费观看视频| 免费在线观看成人| 国产日韩精品一区二区三区在线| 成人高清av在线| 一区二区三区资源| 欧美日韩的一区二区| 精品一区二区国语对白| 国产精品青草综合久久久久99| 99久久久久免费精品国产| 亚洲香蕉伊在人在线观| 精品国产99国产精品| 成人av免费观看| 亚洲一区二区综合| 欧美精品一区二区久久久| av亚洲产国偷v产偷v自拍| 一区二区三区精品在线| 日韩美一区二区三区| 粉嫩aⅴ一区二区三区四区五区| 亚洲精品高清在线| 欧美哺乳videos| 99精品欧美一区二区三区综合在线| 综合久久国产九一剧情麻豆| 欧美日韩国产大片| 国产激情一区二区三区四区| 亚洲欧美国产高清| 欧美成人官网二区| 91天堂素人约啪| 久久精品国产99| 亚洲图片欧美激情| 日韩欧美一区二区免费| 99re8在线精品视频免费播放| 日本成人在线电影网| 国产精品久久午夜夜伦鲁鲁| 在线综合视频播放| 一本大道久久a久久精品综合| 美女精品自拍一二三四| 亚洲精品欧美在线| 国产欧美精品一区二区色综合| 欧美三级视频在线播放| 国产成人超碰人人澡人人澡| 免费成人你懂的| 亚洲午夜在线视频| 成人免费在线播放视频| 久久久久久**毛片大全| 91精品国产入口| 在线观看欧美精品| 91麻豆精东视频| 成人亚洲精品久久久久软件| 狠狠色狠狠色合久久伊人| 日韩精品91亚洲二区在线观看| 一色屋精品亚洲香蕉网站| 2021久久国产精品不只是精品| 777xxx欧美| 欧美午夜在线一二页| 91社区在线播放| caoporn国产精品| 成人黄色综合网站| 国产美女一区二区三区| 另类成人小视频在线| 舔着乳尖日韩一区| 亚洲福利视频三区| 亚洲一二三四在线| 亚洲欧美色图小说| 一区二区三区四区在线播放| 亚洲色图在线播放| 一区二区三区欧美日韩| 亚洲卡通欧美制服中文| 综合电影一区二区三区 | 国产欧美日韩精品在线| 欧美成人aa大片| 精品成人一区二区三区四区| 日韩美女在线视频| 久久久久久久久久久久久夜| 久久综合999| 国产日产欧美一区二区三区| 国产亚洲欧美色| 国产精品护士白丝一区av| 国产精品美女视频| 亚洲精选一二三| 性做久久久久久| 日韩电影在线观看网站| 韩国一区二区视频| 国产精品亚洲一区二区三区在线| 国产精品1024久久| 99国产欧美另类久久久精品| 91九色最新地址| 91精品中文字幕一区二区三区| 日韩欧美另类在线| 国产精品嫩草久久久久| 亚洲精品自拍动漫在线| 天堂午夜影视日韩欧美一区二区| 人禽交欧美网站| 成人在线视频首页| 欧洲在线/亚洲| 欧美一级日韩不卡播放免费| 亚洲国产精品精华液ab| 亚洲精品欧美专区| 久久精品国产亚洲一区二区三区| 国产一区二区美女诱惑| av亚洲精华国产精华精| 欧美肥妇bbw| 国产欧美综合在线观看第十页| 亚洲婷婷综合久久一本伊一区| 视频一区视频二区中文字幕| 国产精品一区在线| 在线精品视频免费观看| 欧美精品一区二区三区很污很色的 | 亚洲国产成人在线| 亚洲一区二区三区四区中文字幕| 精品在线免费观看| 91蜜桃网址入口| 26uuu久久天堂性欧美| 亚洲欧美日韩久久精品| 免费成人在线播放| 91热门视频在线观看| 在线播放亚洲一区| 亚洲色图制服诱惑| 久久99精品国产麻豆不卡| 欧洲精品视频在线观看| 26uuu国产电影一区二区| 亚洲国产综合人成综合网站| 成人免费va视频| 日韩美一区二区三区| 亚洲午夜激情网页| 99久久精品国产毛片| 欧美成人性战久久| 日韩激情视频网站| 懂色一区二区三区免费观看| 日韩一区二区三区三四区视频在线观看| 国产精品美日韩| 激情综合五月婷婷| 日韩欧美中文一区二区| 亚洲午夜视频在线观看| 成人午夜大片免费观看| 日韩欧美激情一区| 日韩影院精彩在线| 在线观看亚洲a| 亚洲欧美一区二区三区孕妇| 高清shemale亚洲人妖| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩激情一二三区| 在线观看日韩高清av| 一区二区三区久久久| 色婷婷精品大在线视频| 亚洲日本青草视频在线怡红院| 国产精品1024久久| 国产日韩欧美综合在线| 九色综合国产一区二区三区| 精品少妇一区二区三区日产乱码 | 亚洲自拍偷拍av| 色综合久久88色综合天天6| 中文字幕第一页久久| 国产成人av电影在线观看| 久久久99精品免费观看不卡| 国产一区二区中文字幕| 久久欧美中文字幕| 成人永久免费视频| 亚洲欧洲精品一区二区三区不卡| av日韩在线网站|