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

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

?? sys_arch.c

?? freertosV4.40 是一種small的嵌入式系統(tǒng)。利于嵌入式開好者入門學習嵌入式操作系統(tǒng)。通過對于源碼的學習可以很好的掌握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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧美综合网| 午夜不卡av免费| 日韩视频中午一区| 99re在线精品| 国产精品系列在线播放| 亚欧色一区w666天堂| 国产清纯在线一区二区www| 欧美电影影音先锋| 91美女在线观看| 国产又粗又猛又爽又黄91精品| 亚洲精品国产视频| 亚洲国产精品ⅴa在线观看| 欧美一级免费观看| 欧美在线观看视频一区二区三区| 国产精品中文字幕欧美| 日本欧美大码aⅴ在线播放| 亚洲综合丁香婷婷六月香| 亚洲成人午夜电影| 亚洲精品福利视频网站| 国产精品的网站| 欧美国产精品一区| 26uuu精品一区二区| 7777精品伊人久久久大香线蕉的 | 亚洲欧洲日韩av| 久久免费看少妇高潮| 91精品国产欧美一区二区成人| 91免费看`日韩一区二区| 成人精品视频网站| 国产suv精品一区二区三区| 国产精品小仙女| 国产盗摄精品一区二区三区在线| 久久激情综合网| 老司机精品视频一区二区三区| 午夜精品福利一区二区蜜股av| 一区二区三区毛片| 亚洲精品综合在线| 一区二区三区四区精品在线视频| 亚洲女人的天堂| 亚洲另类中文字| 亚洲综合久久久久| 午夜精品久久久久久久久久久| 亚洲mv大片欧洲mv大片精品| 亚洲国产一二三| 日韩精品视频网| 蜜臀av一级做a爰片久久| 麻豆精品久久精品色综合| 精品一区二区三区在线观看国产| 久久97超碰国产精品超碰| 激情文学综合丁香| 国产高清无密码一区二区三区| 国产精品一区三区| 国产精品综合二区| 成人午夜视频网站| 91麻豆成人久久精品二区三区| 色成人在线视频| 欧美日韩国产美| 日韩精品一区二区三区四区| 国产亚洲一区二区三区四区| 国产精品美女视频| 亚洲一区二区av在线| 麻豆精品精品国产自在97香蕉| 国产成人免费xxxxxxxx| 91丨九色丨蝌蚪丨老版| 欧洲视频一区二区| 亚洲免费在线观看视频| 亚洲1区2区3区4区| 国产一区久久久| 91蜜桃传媒精品久久久一区二区| 欧美日韩久久一区| 2022国产精品视频| 亚洲精品国产视频| 蜜桃视频免费观看一区| 岛国精品在线观看| 欧美视频在线不卡| www国产成人免费观看视频 深夜成人网| 中日韩av电影| 日韩影院在线观看| 成人国产一区二区三区精品| 欧美日韩美少妇| 国产精品乱子久久久久| 亚洲午夜在线电影| 国产成人免费视频一区| 欧美日本不卡视频| 国产精品视频一区二区三区不卡| 亚洲福利一二三区| 高清不卡在线观看| 欧美放荡的少妇| 日韩毛片在线免费观看| 精品一区二区三区在线播放| 91免费在线视频观看| 精品久久久久久亚洲综合网| 亚洲日韩欧美一区二区在线| 国产一区在线精品| 欧美日本视频在线| 最新日韩av在线| 国产真实精品久久二三区| 欧美三级日韩在线| 日韩久久一区二区| 国产精品自拍三区| 日韩一区二区不卡| 亚洲一区影音先锋| 成人动漫视频在线| 欧美大片国产精品| 香蕉乱码成人久久天堂爱免费| 大陆成人av片| 久久久久久一级片| 蜜臀av性久久久久蜜臀aⅴ| 日本电影亚洲天堂一区| 国产精品天干天干在观线| 伦理电影国产精品| 欧美人狂配大交3d怪物一区| 中文字幕一区二区三区在线观看| 久久97超碰国产精品超碰| 欧美日本一区二区在线观看| 一区二区三区av电影| 成人视屏免费看| 久久精品亚洲一区二区三区浴池 | 国模大尺度一区二区三区| 欧美日韩一级视频| 亚洲人成网站影音先锋播放| 丰满亚洲少妇av| 欧美国产一区在线| 国产精品88888| 久久久精品人体av艺术| 麻豆精品国产传媒mv男同 | 精品国产凹凸成av人导航| 亚洲午夜激情网页| 在线一区二区三区四区| 亚洲老司机在线| 在线看国产一区二区| 18成人在线观看| 一本久道久久综合中文字幕 | 亚洲国产一区视频| 欧美体内she精视频| 一区二区成人在线| 欧美在线|欧美| 亚洲一区二区四区蜜桃| 欧美影片第一页| 亚洲一区二区在线免费看| 色www精品视频在线观看| 樱花草国产18久久久久| 欧美性猛交xxxxxx富婆| 亚洲国产cao| 日韩欧美国产综合在线一区二区三区| 婷婷六月综合网| 欧美成人video| 国产精品18久久久久| 国产精品美女一区二区三区| 91网站最新地址| 午夜不卡av免费| 日韩一区二区三区在线视频| 狠狠久久亚洲欧美| 亚洲国产高清不卡| 欧美性大战久久| 91国偷自产一区二区使用方法| 亚洲资源中文字幕| 日韩欧美国产午夜精品| 国产精品系列在线播放| 综合欧美亚洲日本| 欧美色国产精品| 国内精品在线播放| 中文字幕中文字幕在线一区 | 成人午夜碰碰视频| 一区二区在线看| 欧美成人在线直播| 福利一区福利二区| 亚洲妇熟xx妇色黄| 久久综合一区二区| 91丨porny丨蝌蚪视频| 亚洲成人综合视频| 久久久久99精品国产片| 色先锋资源久久综合| 免费日本视频一区| 中文字幕欧美日韩一区| 欧美日韩久久一区| 国产成人精品免费一区二区| 亚洲最新视频在线观看| 日韩欧美高清一区| 色乱码一区二区三区88| 美日韩一区二区三区| 亚洲女子a中天字幕| 26uuu亚洲| 欧美视频中文字幕| 成人黄色国产精品网站大全在线免费观看| 一区二区高清在线| 国产女同性恋一区二区| 欧美日韩国产经典色站一区二区三区| 国内精品嫩模私拍在线| 亚洲精品久久7777| 国产日韩精品久久久| 欧美日韩成人一区| 不卡的av电影在线观看| 热久久免费视频| 亚洲精品免费一二三区| 久久只精品国产| 宅男在线国产精品| 97精品久久久久中文字幕| 国产精品原创巨作av| 美女在线视频一区| 亚欧色一区w666天堂|