using flags in RTOS in general

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi team

For those who use RTOS, how do you use flags? or what's the alternative of flags in RTOS? I know there is semaphore, but I don't think I should keep posting semaphore right?

For example, that's what I mean if I was using bare metal code.

Code:
volatile uint8_t global_flag = 0;

void scanInput(void);
void doStuff(void);

while(1){
  scanInput();
  doStuff();
}

void scanInput(void){
  // some magical debounce code here
  if (userInput == 1) global_flag = 1;
  else global_flag = 0;
}

void doStuff(void){
  if (global_flag == 1){
    // do stuff
  }
}
 
Top