Skip to content

Commit

Permalink
Merge pull request #1744 from N8Fear/fix-mutex_unlock_and_sleep
Browse files Browse the repository at this point in the history
tests: fix mutex_unlock_and_sleep pids
  • Loading branch information
Hinnerk van Bruinehsen committed Oct 1, 2014
2 parents 2fc0ae2 + 84d48fa commit e37a34d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/mutex_unlock_and_sleep/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

static mutex_t mutex = MUTEX_INIT;
static volatile int indicator, count;
static kernel_pid_t main_pid;

static char stack[KERNEL_CONF_STACKSIZE_MAIN];
static void *second_thread(void *arg)
{
(void) arg;
while (1) {
mutex_lock(&mutex);
thread_wakeup(1);
thread_wakeup(main_pid);
indicator--;
mutex_unlock_and_sleep(&mutex);
}
Expand All @@ -43,7 +44,9 @@ int main(void)
indicator = 0;
count = 0;

thread_create(stack,
main_pid = thread_getpid();

kernel_pid_t second_pid = thread_create(stack,
sizeof(stack),
PRIORITY_MAIN - 1,
CREATE_WOUT_YIELD | CREATE_STACKTEST,
Expand All @@ -53,7 +56,7 @@ int main(void)

while (1) {
mutex_lock(&mutex);
thread_wakeup(2);
thread_wakeup(second_pid);
indicator++;
count++;

Expand Down

0 comments on commit e37a34d

Please sign in to comment.