Results 1 to 2 of 2

Thread: [C++] Events: pthreads or semaphores

  1. #1
    Join Date
    Jun 2009
    Beans
    91

    [C++] Events: pthreads or semaphores

    I'm trying to convert some windows code in C++ to Linux.
    Its not my code, just so you know.

    Anyway, I'm trying to decide what is the best thing to replace "Events" with.
    The code uses CloseHandle(pv_hEvent), SetEvent(pv_hEvent), CreateEvent(NULL, bManualReset, false, NULL) etc

    Here pv_hEvent is of type "HANDLE." And all of these are wrapped up in a class called XEvent. The wait method is infinite, and there is a ResetEvent method, but I intend to skip it as Linux has auto reset only.

    Now, my first thought was to use POSIX semaphores, with semaphore.h, but I'm not sure that's correct. I'm also tempted to use pthreads from pthread.h

    I've been trying to follow these directions: http://www.ibm.com/developerworks/li...-ipc2lin2.html

    but I'm not getting all the info i need from it.

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,273
    Distro
    Kubuntu

    Re: [C++] Events: pthreads or semaphores

    I just worked on a VC++ project that used the CreateEvent(). The application relied on serial port communications to receive/send data.

    I augmented the application to use a UDP socket. I had no need for the "handles" offered by CreateEvent().

    To determine if there is any activity on the UDP socket, I used a select(). If I had developed the code for *nix, I would've done the same.

    Therefore, try to figure out why your application uses CreateEvent(), then determine how that maps over to the *nix world, if at all.

Tags for this Thread

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
  •