Skip to content

Instantly share code, notes, and snippets.

@justbuchanan
Created May 19, 2016 04:31
Show Gist options
  • Save justbuchanan/966fd759e6d5c368c9d71543c2655f32 to your computer and use it in GitHub Desktop.
Save justbuchanan/966fd759e6d5c368c9d71543c2655f32 to your computer and use it in GitHub Desktop.
/*
This is a simple program for the MBED intended to determine what happens if a signal for a thread is
set before the corresponding wait is called. It behaves as expected, so the bug I'm tracking down is somewhere else...
*/
#include <mbed.h>
#include <rtos.h>
#include <cmsis_os.h>
void thread(const void* arg) {
printf("thread waiting on signal 1\r\n");
Thread::signal_wait(1);
printf("thread received signal 1\r\n");
printf("thread waiting on signal 2\r\n");
Thread::signal_wait(2);
printf("thread received signal 2\r\n");
}
int main() {
// set baud rate to higher value than the default for faster terminal
Serial s(MBED_UARTUSB);
s.baud(57600);
printf("\r\n\r\n\r\n************************\r\n");
Thread secondary(thread, nullptr, osPriorityNormal);
Thread::wait(100);
printf("initialized thread\r\n");
Thread::wait(100);
secondary.signal_set(2);
Thread::wait(100);
secondary.signal_set(1);
while (true) {
Thread::yield();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment