Results 1 to 5 of 5

Thread: data at fifo's receiving end has arrived?

  1. #1
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default data at fifo's receiving end has arrived?

    This is related to Linux ,fifo and pthreads.

    How i can come to know that data at receiving end of fifo has arrived. Is there any way to know this asynchronously other than blocked reading or continuous polling.

    situation is such ( presenting in abstract manner): In main thread, an other member-thread is run( Qthread). In this member-thread , i open a fifo for non bloced reading. This fifo will receve values from some other process. And i want to pass these values to main thread.
    2 issues are here:
    1. How i will come to know some-data is available in fifo. Currently i am going for periodic reading?
    2. How to inform this to main thread. Currently whenever i receives something, i send a signal connected to slot of main thread. This makes thread behaves as some function and control passes immediately to main thread-slot. and control do not come back. Ihave started a timer which will keep starting this member-thread.

    here i know ,a lot of things are fishy. I am looking for guidance how to make that well.

    quickNitin

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: data at fifo's receiving end has arrived?

    You can send a unix signal from the sender thread/process after it writes to the pipe and you can handle the signal in the other thread/process. You'll need to do some masking though, so that proper thread receives the signal. And there is no guarantee that the data will be ready to read by then (it should be, but it might not be).

    I hope I understood the problem correctly

  3. #3
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: data at fifo's receiving end has arrived?

    for the question 1, ihave found there is a state based system call select() which gives the state of file descriptors. how it works i have to see? but again , it is not event based.
    Is there any system call which will let kerenel tell me status of fd whenevr some event occurs which i could connect to slot.

  4. #4
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: data at fifo's receiving end has arrived?

    yes wyotsa, you have understood one of them. It strkied me as one of solution. I hadnot implemented this till now as i not much knowledgeable about signals.
    Last edited by quickNitin; 5th November 2006 at 09:30. Reason: bad english

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: data at fifo's receiving end has arrived?

    Quote Originally Posted by quickNitin View Post
    for the question 1, ihave found there is a state based system call select() which gives the state of file descriptors. how it works i have to see? but again , it is not event based.
    Select() polls filedescriptors for their state, so it's not suitable for you if you want to be informed about the event.

    Is there any system call which will let kerenel tell me status of fd whenevr some event occurs which i could connect to slot.
    Not likely. You could check out file monitors (FAM) which have support in the kernel but I don't know if it works for pipes.

    About unix signals - check out manual for signal and sigaction.

Similar Threads

  1. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  2. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 16:17
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.