Thread: Starting a new thread

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    Starting a new thread

    Well I guess technically I did just start a new thread. But anyway...

    I haven't done a huge amount of Linux programming, so my knowledge of the *nix-specific functions is quite limited. I simply need to spawn a new thread,

    The way I have it setup is that I have a function that I'd just like to have running in the background while I continue with the rest of my main thread. I'd like to keep this setup because I'm already using the Win32 function CreateThread() to do the same thing (I'm using preprocessor directives to make the code as platform independent as possible)

    I know about fork(), but from the very little that I've been able to learn about it (Linux documentation seems to have a very different style from MSDN - and I think it'll take me a while to get used to it), it doesn't appear to be exactly what I'm looking for.

    Can anybody give me a bit of guidance here?

  2. #2
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    POSIX threads.

    lookup pthread_create(...) and pthread_t
    {RTFM, KISS}

  3. #3
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    btw, if you're going to be getting into linux programming, this is a good book to have.

    edit:

    or just use http://www.advancedlinuxprogramming.com/alp-folder which i just found on the general forum.
    Last edited by spoon_; 09-04-2005 at 09:13 PM.
    {RTFM, KISS}

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Thanks - the POSIX functions seem to be exactly what I was looking for. However, I was hoping for something that would be fairly standard on *nix machines. I wouldn't have thought a library preceding everything with a 'p' would be standard, but the more I research it, the more it appears to be just assumed to be on any Linux machine. What's the status there?

  5. #5
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    I'm not exactly sure - I've only been heavy into *nix for about 6 months. POSIX implemented threads do seem to be standard though.
    {RTFM, KISS}

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    POSIX implemented threads do seem to be standard though.
    Good enough for me - thanks bud.

  7. #7
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    since posix is the *x standard for portability of apps, yup it's on all *x machines.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Object Creation in thread function
    By sl4nted in forum Windows Programming
    Replies: 18
    Last Post: 10-11-2008, 02:37 PM
  2. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM