Thread: Doing two things at once

  1. #1
    Registered User eam's Avatar
    Join Date
    Oct 2003
    Posts
    53

    Doing two things at once

    I want to make a console program able to output text and do other things while a user is typing input. I'm going to use ncurses for the display. How could I do two things at the same time?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    off the top of my head
    You can use select() on stdin to see if there is any data to be processed

  3. #3
    Code Ripper
    Join Date
    Jun 2004
    Posts
    30
    hi eam,

    you should take a look in fork() and clone() linux syscalls. they work similar to w32 threads.

    jmgk

  4. #4
    Registered User eam's Avatar
    Join Date
    Oct 2003
    Posts
    53
    How would I do that?

  5. #5
    Code Ripper
    Join Date
    Jun 2004
    Posts
    30
    eam,

    already tried http://www.google.com/search?q=linux+fork+syscall ?

    or the linux secret command "man"?

    jmgk

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Actually fork() and clone() are NOT like windows threads. fork() creates another process with its own memory space. If you want multi threaded applications you need to look into pthreads

  7. #7
    Registered User eam's Avatar
    Join Date
    Oct 2003
    Posts
    53
    Guess I have some reading to do then, thanks for pointing me in the right direction.

  8. #8
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    Not to try and say that you are wrong Thantos, just to shed a little more light on the subject. Threads in linux are implemented as their own processes. They just so happen to have the same pid and their address space pointer points to the address space of the other process it is a thread of . They are called lightweight processes.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Suggestions for things to study
    By Mastadex in forum Windows Programming
    Replies: 5
    Last Post: 08-18-2008, 09:23 AM
  2. Plants that eat things
    By StinkyRyan in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 07-05-2004, 03:41 PM
  3. How are things looking
    By cyberCLoWn in forum C++ Programming
    Replies: 8
    Last Post: 01-15-2004, 02:53 PM
  4. Selecting things on the canvas
    By Barjor in forum Windows Programming
    Replies: 0
    Last Post: 08-30-2001, 02:10 PM
  5. Help with these three things...
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-26-2001, 07:05 AM