NPTL, stdin, and keyboard input

NPTL, stdin, and keyboard input

Post by Janos Maka » Tue, 25 May 2004 23:27:00



This is my problem. I made a little test, and the thread which starts
first gets the input. I think the only solution to this problem, to
write my own keyborad handler thread, which forwards the input to the
other threads.

Am I right ?


Janos Makadi
 
 
 

NPTL, stdin, and keyboard input

Post by maki » Tue, 28 Dec 2004 13:43:44

Hello,

I have a little bit complex problem.
Maybe this is not the best place to ask, if it`s not please redirect
me to the proper group.

So, I`m writing an application which handles terminal input with
ncurses in the main code. The user fill forms, use a menu etc...
(common things) It runs 2 threads to wait for an event on the serial
line. When an event comes, the thread have to make an ncurses window,
and wait for one key, from the user. If the user acknowledge the
event, return back to the main job.

My problem is:

It seems the "event" thread has their own stdin, and never get any
keyhit from the keyboard. The main program process the keyboard input
any time.

I know ncurses is not thread safe, but is there any way to combine the
main program`s stdin and the thread`s stdin somehow? Or how can I
solve this situation?

Debian GNU/Linux Sarge
Kernel: 2.6.4 (vanilla)
glibc 2.3.2 with nptl (debian)
gcc 3.3.3 (debian)

THX

Janos Makadi

 
 
 

NPTL, stdin, and keyboard input

Post by Missaka Wi » Tue, 28 Dec 2004 13:43:44

Are the file descriptors for both stdins the same? Since you have two
threads it is possible that the "main" thread gets to stdin before the
other thread (especially since you mentioned that ncurses was not thread
safe). Or, if your serial protocol is simple enough you could make the
program single threaded and multiplex the i/o using poll. BTW, I am not
familiar with curses, so these are simply guesses.

Good luck,
Misk




--
========================================================================
Missaka Wijekoon (a.k.a. Misk) XXXX@XXXXX.COM
Sr. Software Engineer http://www.yqcomputer.com/
VillageEdocs
========================================================================
 
 
 

NPTL, stdin, and keyboard input

Post by Missaka Wi » Tue, 28 Dec 2004 13:43:48

Sure sounds like it.

-Misk





--
========================================================================
Missaka Wijekoon (a.k.a. Misk) XXXX@XXXXX.COM
Sr. Software Engineer http://www.yqcomputer.com/
VillageEdocs
========================================================================
 
 
 

NPTL, stdin, and keyboard input

Post by Janos Maka » Tue, 28 Dec 2004 13:43:49


I`m working on it.

Thanks for your answer...


Janos Makadi