[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithread facilities under Linux



I'm rather busily tring to find my feet in Linux from OS/2 Warp 4. I just
wrote a samll c server / Java client on Warp, using tcp/ip domain sockets. The
c programme has (for now) one thread. The main programme creates an event
semaphore and does a _beginthread(). It posts the semaphore after getting "the
nod" from the Java client. The thread then does its stuff, resets the
semaphore and blocks until the next "nod". It's as simple as that.

I naturally asked myself how would I do that under Linux. And further, how
would I do it for two or three threads.  All this is not academic, since I'll
almost certainly have to provide a Unix (AIX) port in a few months, but
development under Linux.

Here is another one: A few years back I did a citrus packing house production
line control system.
I did the job under OS/2 because Windoze couldn't handle the real time stuff.
It used 3 processes, one multithreaded with event semaphores and timers all
over the place. Again, I'm asking myself, how if at all, I would go about that
sort of thing under Linux.

So, why do I care how it's done: The way you use clone() as compared toOS/2
_beginthread() influences programme design. Let me make it even messier: How
do you want to spin off a thread with visual objects in a X-Motif app? I do it
under OS/2 PM with _beginthread() and it's far from plain sailing.

References: clone() : Linux Application Development, Johnson & Troan, pp
138-139 (not much)
                    semaphores: Advanced Programming in the Unix Environment,
W Richard Stevens ,
                                         pp 457.

guy keren wrote:

> On Wed, 31 Mar 1999, Daniel Feiglin wrote:
>
> > As near as I can figure out, if you want to do serious multithread
> > programming under
> > Linux (say upto 2.0.36 = RH 5.2) you need to use an external pthreads
> > library, several of which are
> > available (no fork/vfork/clone please!). Does anyone know whether these
> > things have been
> > incorporated into the newer 2.2.x kernels e.g. RH 5.9/6.0 etc?
>
> i don't _know_ this in particular, but i _assume_ that it did not occure
> yet. the clone system call was inserted especially in order to allow the
> creation of "light weight processes" and to be used by multi threading
> libraries.
>
> in any case, the programming interface won't change even if/when "real
> threads" will be supported by the kernel, so unless you're looking for
> this for performance reasons, why do you care how it's done?
>
> (as far as i understood, the one thing that's not handled according to the
>  current pthreads standard, is delivery of signals to threads. at least
>  that was the case when using LinuxThreads v0.7).
>
> guy


begin:          vcard
fn:             Daniel Feiglin
n:              Feiglin;Daniel
org:            Dilog Computers Ltd.
adr:            POB 36;;;Shavei Shomron, Mobile Post;;44858;ISRAEL
email;internet: dilogsys@inter.net.il
tel;work:       972 9 861 6204
tel;fax:        972 9 862 1052
tel;home:       972 9 832 0939
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard