Re: creating a thread in c++ in unix (must it be POSIX?)
From: john (qwejohn_at_hotmail.com)
Date: 04/28/03
- Next message: Andrew Gierth: "[READ ME FIRST] Welcome to comp.unix.programmer (v1.21)"
- Previous message: Allin Cottrell: "Re: Library or Source Code for Eigenvalue of Float matrix"
- In reply to: Alex Pavloff: "Re: creating a thread in c++ in unix"
- Next in thread: Paul Pluzhnikov: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Reply: Paul Pluzhnikov: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Reply: Andrew Gierth: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 27 Apr 2003 22:35:10 -0700
Hello,
Thanxs for all the answers in response to my post.
As I understand , all pf you talk about POSIX threads.
Is the only possibility of using thread in UNIX is
by POSIX threads?
I saw , for example, in this newsgroup the following example:
(http://groups.google.com/groups?q=threads+group:comp.unix.programmer&hl=en&lr=&ie=UTF-8&oe=UTF-8&group=comp.unix.programmer&selm=1012544105.263965%40sj-nntpcache-3&rnum=2)
Does it use the POSIX threads?
************* Code ***************
#include <thread.h>
#include <signal.h>
void default_signal_handler(int signal) {
printf("tid = %d in signal handler\n", thr_self());
}
void func(void) {
printf("thread tid = %d created\n", thr_self());
signal(SIGURG, default_signal_handler);
select(0, NULL, NULL, NULL, 0);
while(1);
}
int main() {
unsigned int tid1, tid2;
int ret;
thr_create(NULL, NULL, (void *)func, NULL, THR_DETACHED, &tid1);
thr_create(NULL, NULL, (void *)func, NULL, THR_DETACHED, &tid2);
sleep(1);
thr_kill(tid1, SIGURG);
thr_kill(tid2, SIGURG);
while (1);
}
regards
john
Alex Pavloff <BLAHapavloff@BLAHeason.com> wrote in message news:<me8oavsgkgsko83en767fou8m7sbadmhti@4ax.com>...
> On 27 Apr 2003 03:09:55 -0700, qwejohn@hotmail.com (john) wrote:
>
> >Hello,
> >what is the recommended way of creating a thread in C++
> >in unix?
> >
> >(the parallel of createThread in windows , which creates
> >a thread which , when starts to run , reaches a specified
> >method (which is specified in the createThread call)?
> >regards
> >john
>
> Take a look at the CommonC++ libraries. They provide classes that
> wrap the POSIX api.
>
> http://www.gnu.org/software/commonc++/
- Next message: Andrew Gierth: "[READ ME FIRST] Welcome to comp.unix.programmer (v1.21)"
- Previous message: Allin Cottrell: "Re: Library or Source Code for Eigenvalue of Float matrix"
- In reply to: Alex Pavloff: "Re: creating a thread in c++ in unix"
- Next in thread: Paul Pluzhnikov: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Reply: Paul Pluzhnikov: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Reply: Andrew Gierth: "Re: creating a thread in c++ in unix (must it be POSIX?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|