Threads and C++ under FreeBSD - BSD

This is a discussion on Threads and C++ under FreeBSD - BSD ; Hi all, I am trying to build a simple network server in C++. The server has to spawn threads for every client, that makes a connection . I tried to use pthread_create extern "C" { void *start(void *s){ .... ..... ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Threads and C++ under FreeBSD

  1. Threads and C++ under FreeBSD

    Hi all,

    I am trying to build a simple network server in C++. The server has to
    spawn threads for every client, that makes a connection .


    I tried to use pthread_create

    extern "C" {

    void *start(void *s){
    ....
    .....

    }


    }

    but when I called pthread_create I got SIGSEGV.

    Thats'why I tried also boost and it works fine. The only problem is
    that boost copy the parameters. In this case my socket is just an
    integer and is useless.

    How can I solve this issue ?


    Thanks in advance
    Bobi

  2. Re: Threads and C++ under FreeBSD

    Begin <05ace6ad-d118-45a9-bce5-f5ad0c0de92d@j20g2000hsi.googlegroups.com>
    On Mon, 3 Dec 2007 06:59:53 -0800 (PST),
    borislav.vangelov@googlemail.com wrote:
    [snip: vague segfault report on thread start]
    > Thats'why I tried also boost and it works fine. The only problem is
    > that boost copy the parameters. In this case my socket is just an
    > integer and is useless.
    >
    > How can I solve this issue ?


    What issue? The extra cost of copying one integer is insignificant
    compared to the cost of starting up a thread, and not worth worrying
    about. It's like trying to shave off microseconds off your program
    startup code. The OS overhead drowns it out.

    If it is still a problem, you need a different connection handling model.

    Saying your program segfaults alone is not enough information by far
    to even guess at the problem.


    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

  3. Re: Threads and C++ under FreeBSD

    On Mon, 3 Dec 2007 06:59:53 -0800 (PST), borislav.vangelov@googlemail.com
    wrote:
    > Hi all,
    >
    > I am trying to build a simple network server in C++. The server has to
    > spawn threads for every client, that makes a connection .
    >
    > I tried to use pthread_create
    >
    > extern "C" {
    >
    > void *start(void *s){
    > ...
    > ....
    >
    > }
    >
    >
    > }
    >
    > but when I called pthread_create I got SIGSEGV.


    Where did you get the segfault? Did you try to debug it?

    > Thats'why I tried also boost and it works fine. The only problem is
    > that boost copy the parameters. In this case my socket is just an
    > integer and is useless.
    >
    > How can I solve this issue ?


    What is the problem with copying parameters?

    I guess you have synchronisation problems.

    A bientot
    Paul
    --
    Paul Floyd http://paulf.free.fr

+ Reply to Thread