Commit c4f21e65 authored by rswindell's avatar rswindell
Browse files

Updated kbhit() test for Unix.

parent e26bc5df
......@@ -10,31 +10,13 @@
#include "threadwrap.h"
static void getkey(void);
static void thread_test(void* arg);
typedef struct {
sem_t parent_sem;
sem_t child_sem;
} thread_data_t;
static void thread_test(void* arg)
{
ulong i;
thread_data_t* data = (thread_data_t*)arg;
printf("thread_test entry\n");
sem_post(&data->child_sem);
for(i=0;i<10;i++) {
sem_wait(&data->parent_sem);
printf(" <child>\n");
sem_post(&data->child_sem);
}
printf("thread_test exit\n");
sem_post(&data->child_sem);
}
int main()
{
char compiler[128];
......@@ -63,7 +45,8 @@ int main()
printf("\nkbhit() test (any key to continue)\n");
while(!kbhit()) {
printf(".");
SLEEP(1000);
fflush(stdout);
SLEEP(500);
}
getch(); /* remove character from keyboard buffer */
......@@ -156,3 +139,21 @@ static void getkey(void)
printf("\r%20s\r","");
fflush(stdout);
}
static void thread_test(void* arg)
{
ulong i;
thread_data_t* data = (thread_data_t*)arg;
printf("thread_test entry\n");
sem_post(&data->child_sem);
for(i=0;i<10;i++) {
sem_wait(&data->parent_sem);
printf(" <child>\n");
sem_post(&data->child_sem);
}
printf("thread_test exit\n");
sem_post(&data->child_sem);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment