Page 1 of 1

chThdSuspendS problem

Posted: Mon May 15, 2017 11:48 am
by MySOL93
Hello! Need some help with "Suspend/Wakeup"

Code: Select all


static thread_reference_t* PWaitingThread;

/*
 * Threads
 */

static THD_WORKING_AREA(waThd,512);
static THD_FUNCTION(Thd, arg){
   

   //chSysLock();
     chThdSuspendS(PWaitingThread);
   //chSysUnlock();
   
   while(TRUE) {
      
   
   
   palSetPad(GPIOB, GPIOB_LED4);
   chThdSleepMilliseconds(MS2ST(100));
   palClearPad(GPIOB, GPIOB_LED4);
   chThdSleepMilliseconds(MS2ST(100));
      
   }
}

int main(void) {




    halInit();
     chSysInit();

   
   chThdCreateStatic(waThd, sizeof(waThd), NORMALPRIO+5, Thd, NULL);

   
   while (true) {
   
      chThdSleepMilliseconds(MS2ST(500));
      chSysLockFromISR();
         thread_t *tp= *PWaitingThread;
              chSchReadyI(tp);
      chSysUnlockFromISR();
  }
}


SV#8 error on "chThdSuspendS(PWaitingThread);" in thread. I would be grateful for any help.
Thank you!

Re: chThdSuspendS problem

Posted: Mon May 15, 2017 1:29 pm
by Giovanni
Hi,

S-class functions must be called between a chSysLock() and chSysUnlock(), the state checker is informing you that something is wrong there.

Giovanni

Re: chThdSuspendS problem

Posted: Mon May 15, 2017 4:24 pm
by MySOL93
Giovanni wrote:Hi,

S-class functions must be called between a chSysLock() and chSysUnlock(), the state checker is informing you that something is wrong there.

Giovanni


Thank for answer!
I am uncomment "chSysLock()" and "chSysUnlock()" and now i got SV#4

Re: chThdSuspendS problem

Posted: Mon May 15, 2017 6:04 pm
by Giovanni
The meaning of codes is in this article: http://www.chibios.org/dokuwiki/doku.ph ... ebug_guide

Giovanni

Re: chThdSuspendS problem

Posted: Mon May 15, 2017 8:32 pm
by MySOL93
Giovanni wrote:The meaning of codes is in this article: http://www.chibios.org/dokuwiki/doku.ph ... ebug_guide

Giovanni


Giovanni, thank you for your help