R
Rodney Leger
I have written an app in C on Linux(Redhat 9) that produces a menu and
gives the user a number of options to choose. The menu is in main and
is part of of a while loop.
ie. while(1)
{
printf("1 - Process line 1\n");
......
process data
}
Prior to executing this loop, I set a thread to accept data from
another source.
The data that is accepted in the main while loop and the thread are
independent of each other and unrelated.
status = pthread_create(&thread_id, NULL, receive_loop, NULL);
receive_loop is similar to the main while loop in that it is composed
of a while loop that reads data from another source.
The problem is that the first main while loop only works once and
stops accepting data after it processes the first menu option.
However, the thread continues to process. The receive_loop thread
works flawlessly. When I remove the receive_loop thread call then the
main while loop works flawlessly.
Obviously, I am missing something. Should the main while loop which
is (currently part of main) be setup in its own thread?
What else can I try to resolve this problem.
Your help is appreciated.
Thanks-
Rodney
gives the user a number of options to choose. The menu is in main and
is part of of a while loop.
ie. while(1)
{
printf("1 - Process line 1\n");
......
process data
}
Prior to executing this loop, I set a thread to accept data from
another source.
The data that is accepted in the main while loop and the thread are
independent of each other and unrelated.
status = pthread_create(&thread_id, NULL, receive_loop, NULL);
receive_loop is similar to the main while loop in that it is composed
of a while loop that reads data from another source.
The problem is that the first main while loop only works once and
stops accepting data after it processes the first menu option.
However, the thread continues to process. The receive_loop thread
works flawlessly. When I remove the receive_loop thread call then the
main while loop works flawlessly.
Obviously, I am missing something. Should the main while loop which
is (currently part of main) be setup in its own thread?
What else can I try to resolve this problem.
Your help is appreciated.
Thanks-
Rodney