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

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

?? rt_ipc.c

?? fsmlabs的real time linux的內(nèi)核
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
/* *  rt_ipc.c -- intertask communication primitives for Real-Time Linux * *  Copyright (C) 1997 Jerry Epplin.  All rights reserved. * *  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., 675 Mass Ave, Cambridge, MA 02139, USA. * *  History: *   17-Jul-97 jhe  V0.1 Original. *   28-Jul-97 jhe  V0.2 Timeouts on semaphores.  Message queues. *   15-Aug-97 jhe  V0.3 rt_ipc fifos.  Modified semantics of timeouts. */#define IPC_VERSION "0.3"#include <linux/module.h>#include <linux/config.h>#include <linux/kernel.h>#include <linux/version.h>#include <linux/errno.h>#include <asm/system.h>#include <linux/malloc.h>#include <rtl_sched.h>#include <rtl_sync.h>#include <rtl_fifo.h>#include <asm/rt_irq.h>#include "rt_ipc.h"extern int rtl_schedule(void);#include <rtl_sync.h>#ifdef CONFIG_SMP#error rt_ipc does not work on SMP yetextern spinlock_t fifo_spinlock;#define RTL_SPIN_LOCK fifo_spinlock#endif#define IPC_DATA_INDEX 0/************************************************************************* * rt_sem_init -- initialize a real-time semaphore * * Called to initialize a real-time semaphore.  'sem' must point to a * statically allocated structure.  'type' is RT_SEM_BINARY or  * RT_SEM_COUNTING.  'init_val' is the initial value of the semaphore * (usually 0). * * Returns 0 if successful, -EINVAL if called incorrectly. *************************************************************************/int rt_sem_init(rt_sem_t *sem, RT_SEMTYPE type, int init_val){  int ret = 0;  if (init_val < 0 || (type == RT_SEM_BINARY && init_val > 1))    ret = -EINVAL;		/* binary sem must have 0 or 1 */  else  {    sem->magic = RT_SEM_MAGIC;    sem->val = init_val;    sem->type = type;    sem->wait_list = NULL;  }  return ret;}/************************************************************************* * rt_sem_destroy -- remove a real-time semaphore * * Removes a semaphore previously created with rt_sem_init().  Semaphore * deletion safety is implemented; i.e., any tasks blocked on this  * semaphore when it is destroyed are allowed to run. * * Returns 0 if successful, -EINVAL if 'sem' is not a valid rt_sem_t. *************************************************************************/int rt_sem_destroy(rt_sem_t *sem){  int ret = 0;  if (sem->magic != RT_SEM_MAGIC)    ret = -EINVAL;  else    /* unblock any tasks blocked on this sem */    while (sem->val < 0)      rt_sem_post(sem);  return ret;}/************************************************************************* * unlink_sem_task -- remove a task from a wait list * * Removes a task from the list of tasks waiting on a semaphore. *************************************************************************/static void unlink_sem_task(RT_TASK_ENTRY *to_unlink, rt_sem_t *sem){  if (to_unlink->next != NULL)    to_unlink->next->prev = to_unlink->prev;  if (to_unlink->prev == NULL)    sem->wait_list = to_unlink->next;  else    to_unlink->prev->next = to_unlink->next;}/************************************************************************* * unlink_mq_task -- remove a task from a wait list * * Removes a task from the list of tasks waiting on a message queue. *************************************************************************/static void unlink_mq_task(RT_TASK_ENTRY *to_unlink, rt_mq_t *mq){  if (to_unlink->next != NULL)    to_unlink->next->prev = to_unlink->prev;  if (to_unlink->prev == NULL)    mq->wait_list = to_unlink->next;  else    to_unlink->prev->next = to_unlink->next;}/* cope with the changed priority system */#define GET_PRIO(task) (sched_get_priority_max(0) - (*(task))->sched_param.sched_priority)#define rtl_current (pthread_self()->user[IPC_DATA_INDEX])/* #define rtl_current ((LOCAL_SCHED)-> rtl_current); *//************************************************************************* * rt_sem_post -- semaphore post operation * * The semaphore post (sometimes known as 'give', 'signal', or 'V') operation. * If tasks are waiting for the semaphore, the one with the highest priority * is allowed to run. * * Returns 0 if successful, or -EINVAL if the semaphore is not valid. *************************************************************************/int rt_sem_post(rt_sem_t *sem){  int ret = 0;  int flags;  if (sem->magic != RT_SEM_MAGIC)    ret = -EINVAL;		/* invalid rt_sem_t structure */  else  {    RT_TASK_ENTRY *to_run = NULL;    rtl_critical(flags);    if (sem->val < 0)	/* one or more tasks are waiting for this sem */    {      /* find the waiting task with the highest priority */      RT_TASK_ENTRY *t;      /* search exhaustively all waiting tasks.  I don't want to keep */      /* the list in priority order because I don't want to assume    */      /* the task priorities won't change.                            */      for (t=sem->wait_list ; t!=NULL ; t=t->next)        if (to_run == NULL || GET_PRIO(t->task) < GET_PRIO(to_run->task))          to_run = t;      /* remove the task to be run from the wait_list */      unlink_sem_task(to_run, sem);      /* mark that task as no longer waiting at sem */      ((RT_TASK_IPC *)(to_run->task))->sem_at = NULL;    }    /* binary semaphores never exceed 1 */    if (sem->val < 1 || sem->type == RT_SEM_COUNTING)      ++sem->val;    if (to_run != NULL)    {      /* rt_sem_wait() returned because of a post, not */      /* because of a timeout */      ((RT_TASK_IPC *)(to_run->task))->timed_out = 0;      rt_task_wakeup(to_run->task);    }    rtl_end_critical(flags);  }  return ret;}/************************************************************************* * rt_sem_wait -- semaphore wait operation (blocking) * * The semaphore wait (sometimes known as 'take' or 'P') operation. * If the semaphore is not available, the calling task blocks until * it is.  'timeout' is an optional timeout period.  If 'timeout' is * RT_WAIT_FOREVER, the function does not time out.  If 'timeout' is * RT_NO_WAIT and the semaphore is not available, rt_sem_wait() returns * immediately.  If 'timeout' is any other value, it represent a time  * at which the call to rt_sem_wait() should time out.  If that time * is reached, rt_sem_wait() returns with -ETIME. * * Returns 0 if successful, -ETIME if the operation timed out, -EAGAIN if * RT_NO_WAIT was specified and the semaphore was not available, or -EINVAL * if the semaphore is not valid. *************************************************************************/int rt_sem_wait(rt_sem_t *sem, RTIME timeout){  int ret = 0;  int flags;  if (sem->magic != RT_SEM_MAGIC)    ret = -EINVAL;		/* invalid rt_sem_t structure */  else  {	  rtl_critical(flags);    if (sem->val <= 0)		/* sem not available -- task must wait */    {      if (timeout == RT_NO_WAIT)        ret = -EAGAIN;      else      {        RT_TASK_ENTRY *to_add = &(((RT_TASK_IPC *)rtl_current)->rte);        /* put task on wait_list */        to_add->task = rtl_current;        to_add->prev = NULL;        to_add->next = sem->wait_list;        if (to_add->next != NULL)          to_add->next->prev = to_add;        sem->wait_list = to_add;        /* indicate which sem the task is blocked at */        ((RT_TASK_IPC *)rtl_current)->sem_at = sem;        /* and decrement sem value */        --sem->val;        /* and finally, block */        if (timeout == RT_WAIT_FOREVER)          rt_task_suspend(rtl_current);	/* suspend until post */        else        {          /* assume call timed out.  If this is not the case, */          /* rt_sem_post() will clear this flag */          ((RT_TASK_IPC *)rtl_current)->timed_out = 1;          /* delay until either post occurs or timeout occurs */          rt_task_delay(timeout);          if (((RT_TASK_IPC *)rtl_current)->timed_out)          {            /* timeout occurred -- undo everything and return */            unlink_sem_task(to_add, sem);            ++sem->val;            ret = -ETIME;          }        }      }    }    else      --sem->val;   rtl_end_critical(flags);  }  return ret;}/************************************************************************* * rt_sem_trywait -- semaphore wait operation (unblocking) * * The semaphore wait (sometimes known as 'take' or 'P') operation. * The function returns immediately whether or not the semaphore is * available. * * Returns 0 if successful, -EAGAIN if the semaphore is not available, * or -EINVAL if the semaphore is not valid. *************************************************************************/int rt_sem_trywait(rt_sem_t *sem){  int ret = 0;  int flags;  if (sem->magic != RT_SEM_MAGIC)    ret = -EINVAL;		/* invalid rt_sem_t structure */  else  {	  rtl_critical(flags);    if (sem->val <= 0)		/* sem not available -- task must wait */      ret = -EAGAIN;    else      --sem->val;    rtl_end_critical(flags);  }  return ret;}/************************************************************************* * rt_task_ipc_init -- rt_ipc version of rt_task_init() * * RT-Linux programs using rt_ipc should use rt_task_ipc_init instead of * rt_task_init().  It initializes some rt_ipc variables, then calls * rt_task_init().  Note that all parameters are the same as in rt_task_init() * except 'task', which is an RT_TASK_IPC instead of an RT_TASK. * * Returns 0 if successful, -EINVAL if the 'task' structure is already in * use by another task, or -ENOMEM if a memory allocation error occurred. *************************************************************************/

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区欧美二区| 中文字幕中文字幕一区二区| 久久在线观看免费| 中文字幕av一区二区三区| 亚洲日本在线a| 日本中文字幕一区二区有限公司| 日本v片在线高清不卡在线观看| 久久66热偷产精品| 成人一区二区在线观看| 在线观看日韩精品| 精品美女一区二区| 亚洲视频综合在线| 麻豆久久久久久| 岛国一区二区三区| 91精品蜜臀在线一区尤物| 久久久777精品电影网影网| 亚洲欧美另类在线| 欧美精品一二三四| 国产拍揄自揄精品视频麻豆| 亚洲综合视频在线| 国模一区二区三区白浆| 91婷婷韩国欧美一区二区| 4438成人网| 亚洲青青青在线视频| 裸体一区二区三区| 色欧美88888久久久久久影院| 日韩欧美第一区| 自拍偷拍亚洲激情| 九九热在线视频观看这里只有精品 | 国产一区二区福利| 欧美午夜精品理论片a级按摩| 久久精品亚洲一区二区三区浴池| 亚洲最快最全在线视频| 国产精品99久久不卡二区| 欧美久久久久久蜜桃| 中文av字幕一区| 精品亚洲国产成人av制服丝袜| 色999日韩国产欧美一区二区| 久久久久久夜精品精品免费| 亚洲高清三级视频| www.66久久| 久久久不卡网国产精品二区| 日韩黄色一级片| 色综合中文字幕| 欧美国产97人人爽人人喊| 免费看欧美女人艹b| 精品视频一区二区三区免费| 国产精品久久久久久久久久免费看| 蜜臀国产一区二区三区在线播放| 91论坛在线播放| 中文在线免费一区三区高中清不卡| 奇米色777欧美一区二区| 精品婷婷伊人一区三区三| 亚洲色图欧美激情| 成人午夜精品在线| 国产视频在线观看一区二区三区 | 精品国产青草久久久久福利| 图片区小说区区亚洲影院| 99精品偷自拍| 中文字幕精品在线不卡| 国产一区二区三区综合| 日韩欧美国产一区二区三区| 天天影视网天天综合色在线播放| 色又黄又爽网站www久久| 亚洲欧洲精品天堂一级 | 亚洲视频小说图片| 99久久婷婷国产| 一区在线播放视频| 成人激情免费视频| 国产视频视频一区| 成人小视频在线| 国产农村妇女毛片精品久久麻豆| 国产精品综合视频| 国产日韩欧美一区二区三区乱码| 国产精品一二二区| 国产免费久久精品| 不卡av免费在线观看| 亚洲欧美一区二区视频| av网站免费线看精品| 亚洲欧洲韩国日本视频| 97久久精品人人做人人爽| 成人av网站在线观看| 中文字幕中文字幕在线一区| 9久草视频在线视频精品| 亚洲天堂中文字幕| 欧美最猛性xxxxx直播| 亚洲国产精品久久艾草纯爱| 欧美老女人在线| 麻豆91小视频| 国产拍欧美日韩视频二区| 国产91色综合久久免费分享| 国产精品成人免费精品自在线观看| 成人高清av在线| 亚洲精品日韩一| 欧美日韩黄色影视| 麻豆中文一区二区| 久久久91精品国产一区二区三区| 成a人片亚洲日本久久| 亚洲欧美一区二区不卡| 欧美午夜不卡视频| 蜜桃av一区二区三区| 国产视频视频一区| 91久久免费观看| 日韩电影在线看| 久久先锋影音av| 91麻豆免费在线观看| 丝袜亚洲另类欧美| 亚洲精品在线观看视频| 国产91对白在线观看九色| 亚洲人成电影网站色mp4| 欧美女孩性生活视频| 韩国欧美国产1区| 中文字幕的久久| 欧美最猛黑人xxxxx猛交| 六月丁香婷婷久久| 国产精品久久久久一区二区三区 | 亚洲天堂免费看| 欧美一区二区三区在| 成熟亚洲日本毛茸茸凸凹| 亚洲国产一区视频| 精品久久久久久久一区二区蜜臀| 成人深夜在线观看| 欧美在线你懂的| 精品中文字幕一区二区| 中文字幕在线观看一区二区| 欧美电影在哪看比较好| 国产精品一区不卡| 中文字幕在线观看不卡| 国产精品乡下勾搭老头1| 自拍偷拍亚洲综合| 777xxx欧美| 9i看片成人免费高清| 日韩精彩视频在线观看| 国产日韩欧美麻豆| 欧美性极品少妇| 成人晚上爱看视频| 日韩综合一区二区| 国产精品毛片大码女人| 欧美日产在线观看| youjizz国产精品| 日韩中文字幕麻豆| 中文字幕日韩欧美一区二区三区| 欧美日本在线视频| 国产91在线观看| 午夜电影一区二区三区| 日本一区二区电影| 欧美日韩aaaaaa| 国产一区二区三区最好精华液| 午夜av区久久| 国产精品久久久久久久久快鸭 | 久久久久国产精品麻豆| 91免费国产在线| 麻豆91在线播放| 亚洲国产wwwccc36天堂| 国产精品亲子乱子伦xxxx裸| 欧美日韩1区2区| 99精品黄色片免费大全| 天堂va蜜桃一区二区三区| 亚洲最新视频在线播放| 国产嫩草影院久久久久| 日韩一二三四区| 色琪琪一区二区三区亚洲区| 99久久精品免费看国产 | 欧美tickling网站挠脚心| 色8久久精品久久久久久蜜| 国产风韵犹存在线视精品| 亚洲国产精品久久久久婷婷884| 国产午夜精品理论片a级大结局| 欧美一区二区三区公司| 欧洲精品中文字幕| k8久久久一区二区三区| 久久电影网站中文字幕| 丝袜亚洲精品中文字幕一区| 亚洲免费观看高清完整| 欧美高清在线视频| 久久蜜桃av一区精品变态类天堂 | 亚洲日本中文字幕区| 久久精品夜色噜噜亚洲aⅴ| 亚洲精品一区二区三区99| 欧美精品亚洲二区| 一本一道综合狠狠老| 国产成人精品影视| 爽好多水快深点欧美视频| 亚洲国产日韩在线一区模特| 国产精品久久久一本精品| 久久蜜桃香蕉精品一区二区三区| 欧美一区二区在线播放| av在线综合网| 91麻豆免费在线观看| 91在线精品一区二区三区| 国产二区国产一区在线观看| 麻豆一区二区99久久久久| 久久99久久99| 麻豆精品一区二区综合av| 轻轻草成人在线| 亚洲伊人伊色伊影伊综合网| 亚洲国产精品久久人人爱 | 韩国三级在线一区| 久久99久久久欧美国产| 免费观看一级欧美片|