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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sys_arch.c

?? freertosV4.40 是一種small的嵌入式系統。利于嵌入式開好者入門學習嵌入式操作系統。通過對于源碼的學習可以很好的掌握freertos的運行機制。
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
 * Modifications Copyright (c) 2006 Christian Walter <wolti@sil.at>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * This file is part of the lwIP TCP/IP stack.
 *
 * Author: Adam Dunkels <adam@sics.se>
 * Modifcations: Christian Walter <wolti@sil.at>
 *
 * $Id: sys_arch.c,v 1.6 2006/09/24 22:04:53 wolti Exp $
 */

/* ------------------------ System includes ------------------------------- */
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>

/* ------------------------ FreeRTOS includes ----------------------------- */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

/* ------------------------ lwIP includes --------------------------------- */
#include "lwip/debug.h"
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/mem.h"
#include "lwip/sio.h"
#include "lwip/stats.h"

/* ------------------------ Project includes ------------------------------ */

/* ------------------------ Defines --------------------------------------- */
/* This is the number of threads that can be started with sys_thead_new() */
#define SYS_MBOX_SIZE               ( 16 )
#define MS_TO_TICKS( ms )           \
    ( portTickType )( ( portTickType ) ( ms ) / portTICK_RATE_MS )
#define TICKS_TO_MS( ticks )        \
    ( unsigned portLONG )( ( portTickType ) ( ticks ) * portTICK_RATE_MS )
#define THREAD_STACK_SIZE           ( 1024 )
#define THREAD_NAME                 "lwIP"

#define THREAD_INIT( tcb ) \
    do { \
        tcb->next = NULL; \
        tcb->pid = ( xTaskHandle )0; \
        tcb->timeouts.next = NULL; \
    } while( 0 )

/* ------------------------ Type definitions ------------------------------ */
typedef struct sys_tcb
{
    struct sys_tcb *next;
    struct sys_timeouts timeouts;
    xTaskHandle     pid;
} sys_tcb_t;

/* ------------------------ Prototypes ------------------------------------ */

/* ------------------------ Static functions ------------------------------ */
sys_tcb_t      *sys_thread_current( void );

/* ------------------------ Static variables ------------------------------ */
static sys_tcb_t *tasks = NULL;

/* ------------------------ Start implementation -------------------------- */
void
sys_init( void )
{
    LWIP_ASSERT( "sys_init: not called first", tasks == NULL );
    tasks = NULL;
}

/*
 * This optional function does a "fast" critical region protection and returns
 * the previous protection level. This function is only called during very short
 * critical regions. An embedded system which supports ISR-based drivers might
 * want to implement this function by disabling interrupts. Task-based systems
 * might want to implement this by using a mutex or disabling tasking. This
 * function should support recursive calls from the same task or interrupt. In
 * other words, sys_arch_protect() could be called while already protected. In
 * that case the return value indicates that it is already protected.
 *
 * sys_arch_protect() is only required if your port is supporting an operating
 * system.
 */
sys_prot_t
sys_arch_protect( void )
{
    vPortEnterCritical(  );
    return 1;
}

/*
 * This optional function does a "fast" set of critical region protection to the
 * value specified by pval. See the documentation for sys_arch_protect() for
 * more information. This function is only required if your port is supporting
 * an operating system.
 */
void
sys_arch_unprotect( sys_prot_t pval )
{
    ( void )pval;
    vPortExitCritical(  );
}

/*
 * Prints an assertion messages and aborts execution.
 */
void
sys_assert( const char *msg )
{
	fputs( msg, stderr );
	fputs( "\n\r", stderr );
    vPortEnterCritical(  );
    for( ;; );
}

void
sys_debug( const char *const fmt, ... )
{
    va_list         ap;

    va_start( ap, fmt );
    ( void )vprintf( fmt, ap );
    ( void )putchar( '\r' );
    va_end( ap );
}

/* ------------------------ Start implementation ( Threads ) -------------- */

sys_thread_t
sys_thread_new( void ( *thread ) ( void *arg ), void *arg, int prio )
{
    return sys_arch_thread_new( thread, arg, prio, THREAD_STACK_SIZE );
}

/*
 * Starts a new thread with priority "prio" that will begin its execution in the
 * function "thread()". The "arg" argument will be passed as an argument to the
 * thread() function. The argument "ssize" is the requested stack size for the
 * new thread. The id of the new thread is returned. Both the id and the
  * priority are system dependent.
 */
sys_thread_t
sys_arch_thread_new( void ( *thread ) ( void *arg ), void *arg, int prio, size_t ssize )
{
    sys_thread_t    thread_hdl = SYS_THREAD_NULL;
    int             i;
    sys_tcb_t      *p;
    char            thread_name[ configMAX_TASK_NAME_LEN ];

    /* We disable the FreeRTOS scheduler because it might be the case that the new
     * tasks gets scheduled inside the xTaskCreate function. To prevent this we
     * disable the scheduling. Note that this can happen although we have interrupts
     * disabled because xTaskCreate contains a call to taskYIELD( ).
     */
    vPortEnterCritical(  );

    p = tasks;
    i = 0;
    /* We are called the first time. Initialize it. */
    if( p == NULL )
    {
        p = pvPortMalloc( sizeof( sys_tcb_t ) );
        if( p != NULL )
        {
            tasks = p;
        }
    }
    else
    {
        /* First task already counter. */
        i++;
        /* Cycle to the end of the list. */
        while( p->next != NULL )
        {
            i++;
            p = p->next;
        }
        p->next = pvPortMalloc( sizeof( sys_tcb_t ) );
        p = p->next;
    }

    if( p != NULL )
    {
        /* Memory allocated. Initialize the data structure. */
        THREAD_INIT( p );
        ( void )snprintf( thread_name, configMAX_TASK_NAME_LEN, "lwIP%d", i );

        /* Now q points to a free element in the list. */
        if( xTaskCreate( thread, thread_name, ssize, arg, prio, &p->pid ) == pdPASS )
        {
            thread_hdl = p;
        }
        else
        {
            vPortFree( p );
        }
    }

    vPortExitCritical(  );
    return thread_hdl;
}

void
sys_arch_thread_remove( sys_thread_t hdl )
{
    sys_tcb_t      *current = tasks, *prev;
    sys_tcb_t      *toremove = hdl;
    xTaskHandle     pid = ( xTaskHandle ) 0;

    LWIP_ASSERT( "sys_arch_thread_remove: assertion hdl != NULL failed!", hdl != NULL );

    /* If we have to remove the first task we must update the global "tasks"
     * variable. */
    vPortEnterCritical(  );
    if( hdl != NULL )
    {
        prev = NULL;
        while( ( current != NULL ) && ( current != toremove ) )
        {
            prev = current;
            current = current->next;
        }
        /* Found it. */
        if( current == toremove )
        {
            /* Not the first entry in the list. */
            if( prev != NULL )
            {
                prev->next = toremove->next;
            }
            else
            {
                tasks = toremove->next;
            }
            LWIP_ASSERT( "sys_arch_thread_remove: can't remove thread with timeouts!",
                         toremove->timeouts.next == NULL );
            pid = toremove->pid;
            THREAD_INIT( toremove );
            vPortFree( toremove );
        }
    }
    /* We are done with accessing the shared datastructure. Release the 
     * resources.
     */
    vPortExitCritical(  );
    if( pid != ( xTaskHandle ) 0 )
    {
        vTaskDelete( pid );
        /* not reached. */
    }
}

/*
 * Returns the thread control block for the currently active task. In case

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天影视涩香欲综合网| 欧美军同video69gay| 亚洲一线二线三线久久久| 日韩免费电影一区| 91小宝寻花一区二区三区| 免费在线观看一区二区三区| 中文字幕av一区二区三区免费看| 色8久久精品久久久久久蜜| 国产呦萝稀缺另类资源| 亚洲电影你懂得| 中文字幕五月欧美| 日韩欧美一级片| 欧美日韩一区二区三区高清| 成人激情图片网| 国内精品久久久久影院薰衣草| 亚洲国产视频在线| 最好看的中文字幕久久| 国产欧美一区二区三区沐欲| 91精品国产综合久久香蕉的特点 | 日韩视频中午一区| 色综合久久中文综合久久97| 国产盗摄一区二区| 国精产品一区一区三区mba视频| 丝袜美腿成人在线| 夜夜嗨av一区二区三区四季av| 国产精品欧美一级免费| 久久久噜噜噜久久中文字幕色伊伊| 欧美日韩免费一区二区三区| 一本久久综合亚洲鲁鲁五月天 | 97久久人人超碰| 国产精品538一区二区在线| 五月综合激情网| 亚洲综合丁香婷婷六月香| 亚洲视频1区2区| 中文字幕在线不卡一区| 国产日韩视频一区二区三区| ww亚洲ww在线观看国产| 久久综合色鬼综合色| 日韩无一区二区| 精品国产99国产精品| 欧美大黄免费观看| 欧美一区二区三区四区久久| 7777精品伊人久久久大香线蕉| 欧美三级电影网| 欧美怡红院视频| 欧美手机在线视频| 欧美日韩免费电影| 欧美丰满一区二区免费视频 | 成人av在线播放网址| 成人av综合在线| 色综合久久88色综合天天6| 成人开心网精品视频| 北条麻妃一区二区三区| 99在线视频精品| 91欧美一区二区| 欧洲一区在线电影| 7777女厕盗摄久久久| 精品三级在线看| 国产日韩成人精品| 综合激情网...| 亚洲一区二区四区蜜桃| 肉丝袜脚交视频一区二区| 裸体在线国模精品偷拍| 国产精品一区不卡| 91啦中文在线观看| 91精品视频网| 久久久噜噜噜久噜久久综合| 亚洲人成网站在线| 日韩专区中文字幕一区二区| 国产真实乱对白精彩久久| 丁香天五香天堂综合| 欧美日韩综合不卡| 精品91自产拍在线观看一区| 国产精品久久久久久久久免费樱桃| 亚洲毛片av在线| 久久精品国产久精国产| 成人高清在线视频| 欧美日产国产精品| 日本一区二区免费在线| 亚洲最大成人综合| 韩国三级在线一区| 91福利在线导航| 久久久亚洲午夜电影| 一区二区三区精品久久久| 精品亚洲成a人| 日本精品视频一区二区| 精品国产区一区| 亚洲欧美日韩小说| 国内精品第一页| 欧美性受xxxx黑人xyx性爽| 久久婷婷一区二区三区| 亚洲综合成人在线视频| 丁香啪啪综合成人亚洲小说| 欧美日韩亚洲国产综合| 国产日产欧美一区二区三区| 午夜精品福利在线| av色综合久久天堂av综合| 日韩一区二区麻豆国产| 亚洲视频狠狠干| 国产成人精品免费看| 制服丝袜国产精品| 亚洲精品免费电影| 激情五月播播久久久精品| 欧美系列日韩一区| 国产精品久久夜| 国产综合色视频| 欧美肥妇bbw| 一区二区三区在线视频免费 | 中文字幕一区免费在线观看| 奇米四色…亚洲| 欧美日韩一区视频| 亚洲色图色小说| 大桥未久av一区二区三区中文| 日韩精品一区二区三区视频播放| 一个色综合网站| caoporn国产一区二区| 久久久久久9999| 免播放器亚洲一区| 欧美高清激情brazzers| 亚洲成人一区二区| 欧美日韩中文字幕一区二区| 亚洲精品乱码久久久久久| 成人av电影在线| 国产精品女人毛片| 成人三级在线视频| 欧美国产亚洲另类动漫| 福利一区二区在线观看| 久久精品视频一区二区三区| 老司机精品视频一区二区三区| 在线电影院国产精品| 亚洲国产另类av| 欧美三级一区二区| 亚洲bt欧美bt精品777| 在线欧美日韩国产| 亚洲国产欧美日韩另类综合| 欧美亚洲综合久久| 亚洲福利一区二区三区| 91丨porny丨户外露出| 亚洲色图清纯唯美| 欧美艳星brazzers| 日韩精品电影在线| 精品美女在线播放| 国产乱人伦精品一区二区在线观看 | 最新热久久免费视频| 99天天综合性| 亚洲精品中文在线| 在线观看网站黄不卡| 亚洲国产精品影院| 欧美久久久久中文字幕| 麻豆精品视频在线观看视频| 久久夜色精品国产欧美乱极品| 国产精品系列在线播放| 国产精品久久影院| 欧美影院精品一区| 伦理电影国产精品| 中日韩av电影| 欧美艳星brazzers| 久久爱www久久做| 亚洲国产岛国毛片在线| 91亚洲精品久久久蜜桃| 天堂久久一区二区三区| 精品欧美一区二区三区精品久久| 国产传媒欧美日韩成人| 亚洲免费观看高清完整版在线观看熊| 91黄色免费观看| 美女一区二区视频| 欧美国产禁国产网站cc| 91国内精品野花午夜精品| 另类专区欧美蜜桃臀第一页| 国产精品久久久久aaaa| 欧美日韩不卡一区二区| 国产成人综合在线| 夜夜揉揉日日人人青青一国产精品| 日韩视频在线你懂得| 成人动漫av在线| 日韩av在线免费观看不卡| 中文字幕 久热精品 视频在线| 欧美三级电影在线看| 国产美女主播视频一区| 亚洲激情在线激情| 精品欧美一区二区久久| 91蜜桃网址入口| 精品一区二区三区日韩| 亚洲美女偷拍久久| 久久久国产精品麻豆| 欧美日韩久久久| av不卡在线观看| 美女尤物国产一区| 亚洲制服丝袜一区| 国产女同性恋一区二区| 在线不卡欧美精品一区二区三区| 国产高清精品在线| 日韩激情中文字幕| 亚洲欧美视频在线观看视频| 精品成人免费观看| 在线播放欧美女士性生活| caoporm超碰国产精品| 精品影视av免费| 亚洲国产一区二区三区青草影视 | 亚洲四区在线观看|