⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlist.h

📁 MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis的0.9.5版本的源码。
💻 H
字号:
//  This file is part of MANTIS OS, Operating System//  See http://mantis.cs.colorado.edu/////  Copyright (C) 2003,2004,2005 University of Colorado, Boulder////  This program is free software; you can redistribute it and/or//  modify it under the terms of the mos license (see file LICENSE)/** @file tlist.h * @brief Implements lists for tracking threads. * @author Brian Shucker * @author Modified: Shah Bhatti * @date Modified: 01/01/2004 */#ifndef TLIST_H_#define TLIST_H_#include <inttypes.h>#include "msched.h"/** @brief Thread list data structure (a queue) */typedef struct {   /** @brief Thread at head of queue */   thread_t *head;   /** @brief Thread at tail of queue */   thread_t *tail;} tlist_t;/** @brief Initializes a thread list. */#define mos_tlist_init(list) do {		\      (list)->head = NULL; 			\      (list)->tail = NULL;			\   } while(0)/** @brief Adds a new thread to end of thread list. * @param list Thread list to add to * @param item Thread to add to list */#define mos_tlist_add(list,item) do {		\      if((list)->head == NULL) {		\	 (list)->head = item;			\	 (list)->tail = item;			\	 (item)->next = NULL;			\      } else {					\	 (list)->tail->next = item;		\	 (list)->tail = item;			\	 (item)->next = NULL;			\      }						\   } while(0)/** @brief Removes thread from front of thread list. * @param list Thread list to remove from * @return Thread removed from list (NULL if empty) */thread_t *mos_tlist_remove(tlist_t *list);/** @brief Removes specific thread from thread list. * @param list Thread list to remove from * @param id id of thread to remove * @return Thread removed (NULL if empty) */thread_t *mos_tlist_get_thread(tlist_t *list, uint16_t id);/** @brief Adds a new thread to ordered thread list. */void mos_tlist_ordadd(tlist_t *list, thread_t *item);/** @brief Adjusts the sleepQ with elapsed time.  */#define mos_tlist_adjustst(list,atime) do {	\      thread_t *adjust_front = (list)->head;	\      while(adjust_front) {			\	 if(atime > adjust_front->st) {		\	    atime -= adjust_front->st;		\	    adjust_front->st = 0;		\	    adjust_front = adjust_front->next;	\	 } else {				\	    adjust_front->st -= atime;		\	    break;				\	 }					\      }						\   } while(0)/** @brief Pointer to thread at the front of thread list. * @param list Thread list to get thread from * @return Thread removed from list (NULL if empty) */#define mos_tlist_head(list) (list)->head#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -