C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-03-2004, 10:22 PM   #1
eam
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?
eam is offline   Reply With Quote
Old 08-03-2004, 10:27 PM   #2
& the hat of GPL slaying
 
Thantos's Avatar
 
Join Date: Sep 2001
Posts: 5,732
off the top of my head
You can use select() on stdin to see if there is any data to be processed
Thantos is offline   Reply With Quote
Old 08-03-2004, 10:51 PM   #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
jmgk is offline   Reply With Quote
Old 08-03-2004, 10:52 PM   #4
eam
Registered User
 
eam's Avatar
 
Join Date: Oct 2003
Posts: 53
How would I do that?
eam is offline   Reply With Quote
Old 08-03-2004, 11:07 PM   #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
jmgk is offline   Reply With Quote
Old 08-03-2004, 11:09 PM   #6
& the hat of GPL slaying
 
Thantos's Avatar
 
Join Date: Sep 2001
Posts: 5,732
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
Thantos is offline   Reply With Quote
Old 08-03-2004, 11:51 PM   #7
eam
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.
eam is offline   Reply With Quote
Old 08-04-2004, 10:10 PM   #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
chrismiceli is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 03:08 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22