0

私はcで眠っている床屋の練習をしようとしていますが、何が悪いのかわかりません。誰かが私を素人の言葉で説明してくれるので、それを修正するために何をする必要があるか教えてください. 私はこのメッセージを受け取り続けます:

app_main.c、72 行目: エラー: void 値が無視されない app_main.c、73 行目: エラー: void 値が無視されないはずです

#define TASK0_PIN 0x80
INT8U err;
INT8U  err2;
void Task0(void *dptr)
{


       int value = OSSemPend(Barber,1,err); //aquire semaphore to perform barber
       int value2 = OSSemPend(FreeSeats,1,err2);

それが問題の領域です。以下にコード全体を示します。

   /*
    **********************************************************
    * uCOSII example 0
    *
    * uCOS uses prioritized preemptive scheduling.
    *
    * This example program contains 2 tasks:
    * Task0 has lower priority (5) and can be preempted by task1.
    * Task1 has higher priority (3).
    **********************************************************
    */
    #include "ucos_ii.h"
    #include <stdio.h>
    #include <avr/io.h>
    #include <avr/interrupt.h>
     OS_EVENT *Barber;
     OS_EVENT *FreeSeats;


    int Customers;
    //int Barber;
    //int FreeSeats; //total number of seats

    int Ready;
    int  Ready2;
    int value;
    int value2;


    OS_STK Task0Stk[TASK0_STK_SIZE] __attribute__ ((section (".bss.stacks")));
    OS_STK Task1Stk[TASK1_STK_SIZE] __attribute__ ((section (".bss.stacks")));
    OS_STK Task2Stk[TASK2_STK_SIZE] __attribute__ ((section (".bss.stacks")));
    int status;

    void   Task0(void *objdata);
    void   Task1(void *objdata);
    void   Task2(void *objdata);

    int main(void)
    {
      OSInit();
      status=OSTaskCreate(Task0,(void *)NULL,(OS_STK *)&Task0Stk[TASK0_STK_SIZE - 1], TASK0_PRIO);
      status=OSTaskCreate(Task1,(void *)NULL,(OS_STK *)&Task1Stk[TASK1_STK_SIZE - 1], TASK1_PRIO);
      status=OSTaskCreate(Task2,(void *)NULL,(OS_STK *)&Task2Stk[TASK2_STK_SIZE - 1], TASK2_PRIO);




     Customers = 0;
      Barber = OSSemCreate(1); //total nro of barbers
    FreeSeats = OSSemCreate(2); //total number of seats

    Ready= OSSemPost(Barber); // release semaphore
   Ready2= OSSemPost(FreeSeats);

      OSStart();  //OSStart never returns
      return 0;
    }

    //------------------------------------------------------------------
    // Task0 toggles pin PD7 every 3. OS tick (=3 msec with default tick 1 msec)
    //------------------------------------------------------------------
    #define TASK0_PIN 0x80
    INT8U err;
    INT8U  err2;
    void Task0(void *dptr)
    {
    //||



               value = OSSemPend(Barber,1,err); //aquire semaphore to perform barber
                  value2 = OSSemPend(FreeSeats,1,err2);

     if (value<1 || value2<1 )//if barber or seat are not available then wait
      {
      OSTimeDly(3);
      }
      else
    {


      DDRD|=TASK0_PIN;
      for (;;) {
        PORTD^=TASK0_PIN;
        OSTimeDly(3); //wait 3 msec

     Ready;  //increment the semaphore and remove the task with highest priority from list and make it ready to run
     Ready2;
      }
    }
    }
    //------------------------------------------------------------------
    // Task0 toggles pin PD6 every OS tick (default 1 msec)
    //------------------------------------------------------------------
    #define TASK1_PIN 0x40
    void Task1(void *dptr)
    {

     Customers +1;
      if (FreeSeats >= 2)
      {
        FreeSeats -2;
      dptr=dptr;
      DDRD|=TASK1_PIN;
      for (;;) {
        PORTD^=TASK1_PIN;
      FreeSeats  +2;
      Customers -1;
        OSTimeDly(1); //wait 1 system tick
      }
       }
       else
    {
     OSTimeDly(3);
     Task1;
    }

    }

    //------------------------------------------------------------------
    // Task2 toggles pin PD6 every OS tick (default 1 msec)
    //------------------------------------------------------------------
    #define TASK2_PIN 0x20
    void Task2(void *dptr)
    {
       Customers +1;
      if (FreeSeats >= 2)
      {
        FreeSeats -2;

      dptr=dptr;
      DDRD|=TASK2_PIN;
      for (;;) {
        PORTD^=TASK2_PIN;
          FreeSeats  +2;
             Customers -1;
        OSTimeDly(2); //wait 1 system tick
      }
      }

     else
    {
     OSTimeDly(3);
     Task2;
    }

    }
4

1 に答える 1

2

OSSemPend は void を返し、戻り値をvalueおよびvalue2

それはおそらくあなたが望むように見えます

OSSemPend(Barber,1,&err); //aquire semaphore to perform barber
OSSemPend(FreeSeats,1,&err2);
if (err != 0 || err2 != 0 )//if barber or seat are not available then wait

それかあなたが使いたい

value = OSSemPend(Barber,1);
value2 = OSSemPend(FreeSeats,1,);
于 2012-11-28T21:05:00.280 に答える