zoukankan      html  css  js  c++  java
  • 任哲版《嵌入式实时操作系统 ucos ii》笔记【1】--------基本数据结构TCB

     1 #include<stdio.h>
     2 #include<string.h>
     3 
     4 //declare the Tcb struch
     5 
     6 typedef struct tcb{
     7     char * code_name;
     8     int p;
     9     int num;
    10     void (*fun)();
    11 }TCB;
    12 
    13 void function1()
    14 {
    15     printf("11111111111111111111
    ");
    16 }
    17 
    18 void function2()
    19 {
    20     printf("2222222222222222222222
    ");
    21 }
    22 
    23 void function3()
    24 {
    25     printf("333333333333333333333333
    ");
    26 }
    27 
    28 TCB CreateTcb(char *name, int pp, int nqq, void (*f)())
    29 {        
    30         TCB tcb2;
    31         tcb2.code_name = name;
    32         tcb2.p = pp;
    33         tcb2.num = nqq;
    34         tcb2.fun = f; 
    35         return tcb2;
    36 }
    37 
    38 int main()
    39 {    TCB tcbtt[3];
    40     char code_name1[10];
    41     int t,i;
    42     
    43     tcbtt[0] = CreateTcb("first",2,1,function1);
    44     tcbtt[1] = CreateTcb("second",2,2,function2);
    45     tcbtt[2] = CreateTcb("third",2,3,function3);
    46     printf("Input the number of the function:
    ");
    47     
    48     scanf("%s",&code_name1);
    49     t = 0;
    50 
    51     for (i = 0;i<3;i++)
    52         {
    53             if(strcmp(tcbtt[i].code_name ,code_name1) ==0)
    54             {
    55                 tcbtt[i].fun();
    56                 t=1;
    57             }
    58             if((i == 2) && (t== 0))
    59             printf("NO %s",code_name1);
    60         }

    需要注意以下2个地方:

    ok,圆满了·····留下了,以后看·

  • 相关阅读:
    jq动画效果
    each循环和节点操作
    jquery的基础语法
    JS作用域
    DOM事件
    js语法一
    socketserver模块与mysql语句(一)
    亲测idea编辑器控制台中文乱码成功的解决方法
    PHP Fatal error: Call to undefined function json_decode()
    PHP <? 标签问题导致不能正确运行代码
  • 原文地址:https://www.cnblogs.com/kalo1111/p/3296491.html
Copyright © 2011-2022 走看看