Skip to content

Commit

Permalink
Make sure the FIFO example is initialized properly
Browse files Browse the repository at this point in the history
  • Loading branch information
shengwen-tw committed Feb 5, 2024
1 parent abfdabc commit 8458158
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions user/tasks/examples/fifo-ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define TEST_STR "[fifo example] hello world\n\r"
#define LEN strlen(TEST_STR)

static bool fifo_ready = false;

void fifo_task1(void)
{
setprogname("fifo-ex-1");
Expand All @@ -21,6 +23,8 @@ void fifo_task1(void)
exit(1);
}

fifo_ready = true;

int fifo_fd = open("/fifo_test", O_RDWR);
if (fifo_fd < 0) {
exit(1);
Expand All @@ -36,6 +40,9 @@ void fifo_task2(void)
{
setprogname("fifo-ex-2");

while (!fifo_ready)
;

int fifo_fd = open("/fifo_test", 0);
if (fifo_fd < 0) {
exit(1);
Expand Down

0 comments on commit 8458158

Please sign in to comment.