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

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

?? demo.c

?? Threadx 模版的源代碼
?? C
字號:
/* This is a small demo of the high-performance ThreadX kernel.  It includes examples of eight
   threads of different priorities, using a message queue, semaphore, mutex, event flags group, 
   byte pool, and block pool.  */

#include   "tx_api.h"
#include   <stdio.h>

#define     DEMO_STACK_SIZE         1024
#define     DEMO_BYTE_POOL_SIZE     9120
#define     DEMO_BLOCK_POOL_SIZE    100
#define     DEMO_QUEUE_SIZE         100


/* Define the ThreadX object control blocks...  */

TX_THREAD               thread_0;
TX_THREAD               thread_1;
TX_THREAD               thread_2;
TX_THREAD               thread_3;
TX_THREAD               thread_4;
TX_THREAD               thread_5;
TX_THREAD               thread_6;
TX_THREAD               thread_7;
TX_QUEUE                queue_0;
TX_SEMAPHORE            semaphore_0;
TX_MUTEX                mutex_0;
TX_EVENT_FLAGS_GROUP    event_flags_0;
TX_BYTE_POOL            byte_pool_0;
TX_BLOCK_POOL           block_pool_0;


/* Define the counters used in the demo application...  */

ULONG           thread_0_counter;
ULONG           thread_1_counter;
ULONG           thread_1_messages_sent;
ULONG           thread_2_counter;
ULONG           thread_2_messages_received;
ULONG           thread_3_counter;
ULONG           thread_4_counter;
ULONG           thread_5_counter;
ULONG           thread_6_counter;
ULONG           thread_7_counter;


/* Define thread prototypes.  */

void    thread_0_entry(ULONG thread_input);
void    thread_1_entry(ULONG thread_input);
void    thread_2_entry(ULONG thread_input);
void    thread_3_and_4_entry(ULONG thread_input);
void    thread_5_entry(ULONG thread_input);
void    thread_6_and_7_entry(ULONG thread_input);


/* Define main entry point.  */

int main()
{

    /* Enter the ThreadX kernel.  */
    tx_kernel_enter();
}


/* Define what the initial system looks like.  */

void    tx_application_define(void *first_unused_memory)
{

CHAR    *pointer;


    /* Create a byte memory pool from which to allocate the thread stacks.  */
    tx_byte_pool_create(&byte_pool_0, "byte pool 0", first_unused_memory, DEMO_BYTE_POOL_SIZE);

    /* Put system definition stuff in here, e.g. thread creates and other assorted
       create information.  */

    /* Allocate the stack for thread 0.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create the main thread.  */
    tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,  
            pointer, DEMO_STACK_SIZE, 
            1, 1, TX_NO_TIME_SLICE, TX_AUTO_START);


    /* Allocate the stack for thread 1.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 1 and 2. These threads pass information through a ThreadX 
       message queue.  It is also interesting to note that these threads have a time
       slice.  */
    tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 2.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,  
            pointer, DEMO_STACK_SIZE, 
            16, 16, 4, TX_AUTO_START);

    /* Allocate the stack for thread 3.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 3 and 4.  These threads compete for a ThreadX counting semaphore.  
       An interesting thing here is that both threads share the same instruction area.  */
    tx_thread_create(&thread_3, "thread 3", thread_3_and_4_entry, 3,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 4.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_4, "thread 4", thread_3_and_4_entry, 4,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 5.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create thread 5.  This thread simply pends on an event flag which will be set
       by thread_0.  */
    tx_thread_create(&thread_5, "thread 5", thread_5_entry, 5,  
            pointer, DEMO_STACK_SIZE, 
            4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 6.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    /* Create threads 6 and 7.  These threads compete for a ThreadX mutex.  */
    tx_thread_create(&thread_6, "thread 6", thread_6_and_7_entry, 6,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the stack for thread 7.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_STACK_SIZE, TX_NO_WAIT);

    tx_thread_create(&thread_7, "thread 7", thread_6_and_7_entry, 7,  
            pointer, DEMO_STACK_SIZE, 
            8, 8, TX_NO_TIME_SLICE, TX_AUTO_START);

    /* Allocate the message queue.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_QUEUE_SIZE*sizeof(ULONG), TX_NO_WAIT);

    /* Create the message queue shared by threads 1 and 2.  */
    tx_queue_create(&queue_0, "queue 0", TX_1_ULONG, pointer, DEMO_QUEUE_SIZE*sizeof(ULONG));

    /* Create the semaphore used by threads 3 and 4.  */
    tx_semaphore_create(&semaphore_0, "semaphore 0", 1);

    /* Create the event flags group used by threads 1 and 5.  */
    tx_event_flags_create(&event_flags_0, "event flags 0");

    /* Create the mutex used by thread 6 and 7 without priority inheritance.  */
    tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);

    /* Allocate the memory for a small block pool.  */
    tx_byte_allocate(&byte_pool_0, (VOID **) &pointer, DEMO_BLOCK_POOL_SIZE, TX_NO_WAIT);

    /* Create a block memory pool to allocate a message buffer from.  */
    tx_block_pool_create(&block_pool_0, "block pool 0", sizeof(ULONG), pointer, DEMO_BLOCK_POOL_SIZE);

    /* Allocate a block and release the block memory.  */
    tx_block_allocate(&block_pool_0, (VOID **) &pointer, TX_NO_WAIT);

    /* Release the block back to the pool.  */
    tx_block_release(pointer);
}



/* Define the test threads.  */

void    thread_0_entry(ULONG thread_input)
{

UINT    status;


    /* This thread simply sits in while-forever-sleep loop.  */
    while(1)
    {

        /* Increment the thread counter.  */
        thread_0_counter++;

        /* Print results.  */
        printf("**** ThreadX Win32 Demonstration **** (c) 1996-2004 Express Logic, Inc.\n\n");

        printf("           thread 0 events sent:          %lu\n", thread_0_counter);
        printf("           thread 1 messages sent:        %lu\n", thread_1_counter);
        printf("           thread 2 messages received:    %lu\n", thread_2_counter);
        printf("           thread 3 obtained semaphore:   %lu\n", thread_3_counter);
        printf("           thread 4 obtained semaphore:   %lu\n", thread_4_counter);
        printf("           thread 5 events received:      %lu\n", thread_5_counter);
        printf("           thread 6 mutex obtained:       %lu\n", thread_6_counter);
        printf("           thread 7 mutex obtained:       %lu\n\n", thread_7_counter);

        /* Sleep for 10 ticks.  */
        tx_thread_sleep(10);

        /* Set event flag 0 to wakeup thread 5.  */
        status =  tx_event_flags_set(&event_flags_0, 0x1, TX_OR);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;
    }
}


void    thread_1_entry(ULONG thread_input)
{

UINT    status;


    /* This thread simply sends messages to a queue shared by thread 2.  */
    while(1)
    {

        /* Increment the thread counter.  */
        thread_1_counter++;

        /* Send message to queue 0.  */
        status =  tx_queue_send(&queue_0, &thread_1_messages_sent, TX_WAIT_FOREVER);

        /* Check completion status.  */
        if (status != TX_SUCCESS)
            break;

        /* Increment the message sent.  */
        thread_1_messages_sent++;
    }
}


void    thread_2_entry(ULONG thread_input)
{

ULONG   received_message;
UINT    status;

    /* This thread retrieves messages placed on the queue by thread 1.  */
    while(1)
    {

        /* Increment the thread counter.  */
        thread_2_counter++;

        /* Retrieve a message from the queue.  */
        status = tx_queue_receive(&queue_0, &received_message, TX_WAIT_FOREVER);

        /* Check completion status and make sure the message is what we 
           expected.  */
        if ((status != TX_SUCCESS) || (received_message != thread_2_messages_received))
            break;
        
        /* Otherwise, all is okay.  Increment the received message count.  */
        thread_2_messages_received++;
    }
}


void    thread_3_and_4_entry(ULONG thread_input)
{

UINT    status;


    /* This function is executed from thread 3 and thread 4.  As the loop
       below shows, these function compete for ownership of semaphore_0.  */
    while(1)
    {

        /* Increment the thread counter.  */
        if (thread_input == 3)
            thread_3_counter++;
        else
            thread_4_counter++;

        /* Get the semaphore with suspension.  */
        status =  tx_semaphore_get(&semaphore_0, TX_WAIT_FOREVER);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;

        /* Sleep for 2 ticks to hold the semaphore.  */
        tx_thread_sleep(2);

        /* Release the semaphore.  */
        status =  tx_semaphore_put(&semaphore_0);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;
    }
}


void    thread_5_entry(ULONG thread_input)
{

UINT    status;
ULONG   actual_flags;


    /* This thread simply waits for an event in a forever loop.  */
    while(1)
    {

        /* Increment the thread counter.  */
        thread_5_counter++;

        /* Wait for event flag 0.  */
        status =  tx_event_flags_get(&event_flags_0, 0x1, TX_OR_CLEAR, 
                                                &actual_flags, TX_WAIT_FOREVER);

        /* Check status.  */
        if ((status != TX_SUCCESS) || (actual_flags != 0x1))
            break;
    }
}


void    thread_6_and_7_entry(ULONG thread_input)
{

UINT    status;


    /* This function is executed from thread 6 and thread 7.  As the loop
       below shows, these function compete for ownership of mutex_0.  */
    while(1)
    {

        /* Increment the thread counter.  */
        if (thread_input == 6)
            thread_6_counter++;
        else
            thread_7_counter++;

        /* Get the mutex with suspension.  */
        status =  tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;

        /* Get the mutex again with suspension.  This shows
           that an owning thread may retrieve the mutex it
           owns multiple times.  */
        status =  tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;

        /* Sleep for 2 ticks to hold the mutex.  */
        tx_thread_sleep(2);

        /* Release the mutex.  */
        status =  tx_mutex_put(&mutex_0);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;

        /* Release the mutex again.  This will actually 
           release ownership since it was obtained twice.  */
        status =  tx_mutex_put(&mutex_0);

        /* Check status.  */
        if (status != TX_SUCCESS)
            break;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
伊人性伊人情综合网| 奇米色一区二区三区四区| 国产精品久久久久久亚洲毛片 | 亚洲bt欧美bt精品777| 一区二区高清免费观看影视大全 | 在线观看日韩高清av| 欧美一二区视频| 国产婷婷一区二区| 一区二区三区中文字幕在线观看| 亚洲永久精品大片| 国产酒店精品激情| 91福利国产精品| 3d成人动漫网站| 国产精品私房写真福利视频| 偷拍亚洲欧洲综合| 成人精品国产一区二区4080| 欧美日韩免费不卡视频一区二区三区| 久久久久久久久久久久电影| 午夜视频一区二区三区| 国产成人精品网址| 欧美一区二区成人6969| 日韩美女视频一区二区 | wwwwww.欧美系列| 亚洲精品免费在线播放| 蜜芽一区二区三区| 99久久婷婷国产综合精品电影| 欧美日韩在线直播| 亚洲欧美日韩系列| 国产成人精品一区二| 欧美唯美清纯偷拍| 国产精品天天摸av网| 麻豆视频一区二区| 欧美日韩国产高清一区二区三区| 国产农村妇女毛片精品久久麻豆| 亚洲bt欧美bt精品| 色综合久久久久久久久久久| 久久久噜噜噜久久中文字幕色伊伊| 亚洲综合成人在线| 91色|porny| 久久久久久久久久久久久久久99| 蜜臀av亚洲一区中文字幕| 精品视频1区2区| 亚洲电影激情视频网站| 欧美无乱码久久久免费午夜一区| 中文字幕五月欧美| 99久久精品免费精品国产| 久久久久久久久久电影| 美女被吸乳得到大胸91| 日韩一区二区免费高清| 老司机精品视频线观看86| 日韩欧美国产小视频| 国产在线不卡视频| 亚洲免费观看视频| 久久久91精品国产一区二区精品 | 欧美顶级少妇做爰| 国产乱对白刺激视频不卡 | 欧美片在线播放| 图片区日韩欧美亚洲| 成人app下载| 日韩精品高清不卡| 久久久久久一级片| 99精品视频在线播放观看| 中文在线资源观看网站视频免费不卡 | 亚洲18女电影在线观看| 欧美一区二区黄| 国产一区啦啦啦在线观看| 欧美mv日韩mv亚洲| 99久久精品久久久久久清纯| 亚洲一区二区四区蜜桃| 日韩一级欧美一级| 色先锋资源久久综合| 日韩福利电影在线观看| 久久久精品国产99久久精品芒果| 97精品国产97久久久久久久久久久久| 亚洲一区在线观看免费观看电影高清 | 久久av老司机精品网站导航| 成人欧美一区二区三区1314| 日韩一区二区三区四区五区六区| 国产suv精品一区二区三区| 亚洲欧美欧美一区二区三区| 欧美成人女星排行榜| 欧美美女一区二区在线观看| 在线观看欧美黄色| 成人激情动漫在线观看| 久久精品国产99国产| 亚洲一区av在线| 亚洲欧美日韩中文字幕一区二区三区| 亚洲一区二区精品久久av| 国产精品国产a级| 2023国产精品| 制服丝袜亚洲播放| 欧美美女一区二区| 色94色欧美sute亚洲13| 成人精品在线视频观看| 久久se精品一区精品二区| 亚洲123区在线观看| 国产精品久久久久影院| 久久久久久99久久久精品网站| 日韩一级片网址| 欧美一卡在线观看| 337p亚洲精品色噜噜狠狠| 欧美日本乱大交xxxxx| 欧美日韩免费观看一区二区三区| thepron国产精品| 色婷婷av一区二区三区软件 | 欧美午夜精品电影| 欧美日韩国产免费一区二区| 成人精品免费看| 欧美性生活大片视频| 欧美视频在线观看一区| 欧美一区二区日韩一区二区| 欧美精品第1页| 精品少妇一区二区三区视频免付费 | 色综合久久精品| 在线一区二区视频| 欧美一区二区三区人| 日韩欧美国产一区二区三区| 欧美一级夜夜爽| 国产日产欧美一区| 综合av第一页| 免费人成在线不卡| 美女久久久精品| av亚洲精华国产精华精| 欧美日韩一区高清| 欧美精品一区二区精品网| 亚洲欧洲一区二区三区| 日韩精品福利网| av资源网一区| 8x8x8国产精品| 久久精品一二三| 亚洲一区二区三区视频在线| 精品一区二区三区免费毛片爱| 99麻豆久久久国产精品免费优播| 欧美剧情电影在线观看完整版免费励志电影 | 欧美精品丝袜久久久中文字幕| 精品电影一区二区| 亚洲一级二级在线| 99精品偷自拍| 国产精品电影一区二区| 国模大尺度一区二区三区| 欧美日韩高清不卡| 亚洲欧美偷拍另类a∨色屁股| 久99久精品视频免费观看| 91蜜桃传媒精品久久久一区二区| 日韩欧美一区二区免费| 亚洲综合色视频| 国产不卡在线一区| 久久久亚洲欧洲日产国码αv| 一区二区久久久久久| 91美女视频网站| 亚洲欧美一区二区三区国产精品| 国产不卡高清在线观看视频| xfplay精品久久| 精品一区二区久久| 欧美videos中文字幕| 美日韩一区二区三区| 在线观看视频一区二区| 国产精品夫妻自拍| 色播五月激情综合网| 一区二区三区四区在线| 欧美曰成人黄网| 石原莉奈在线亚洲三区| 欧美一区二区三区四区高清| 久久99热狠狠色一区二区| 日韩美女一区二区三区四区| 久久av中文字幕片| 国产校园另类小说区| 成人黄色综合网站| 亚洲高清视频在线| 精品国产乱子伦一区| 欧美日韩黄视频| 精品在线亚洲视频| 国产欧美精品国产国产专区| 一本色道久久综合亚洲91| 亚洲欧美日韩成人高清在线一区| 91精品国产综合久久国产大片 | 精品欧美一区二区久久| 国产成人欧美日韩在线电影| 国产精品嫩草影院com| 欧美日韩精品欧美日韩精品| 国产资源精品在线观看| 亚洲视频资源在线| 日韩视频中午一区| av影院午夜一区| 毛片av一区二区三区| 久久久亚洲精品石原莉奈| 91精品国产黑色紧身裤美女| 成人性生交大片免费看视频在线 | 国产不卡高清在线观看视频| 亚洲一区在线免费观看| 欧美mv日韩mv亚洲| 欧美伊人精品成人久久综合97| 国产在线看一区| 亚洲v中文字幕| 亚洲欧美自拍偷拍| 久久女同精品一区二区| 欧美一区二区精品在线| 在线免费观看视频一区| 成人动漫av在线| 国产综合色精品一区二区三区|