Search Results

Search found 166 results on 7 pages for 'pthreads'.

Page 4/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • get return value from 2 threads in C

    - by polslinux
    #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <stdint.h> #include <inttypes.h> typedef struct tmp_num{ int tmp_1; int tmp_2; }t_num; t_num t_nums; void *num_mezzo_1(void *num_orig); void *num_mezzo_2(void *num_orig); int main(int argc, char *argv[]){ pthread_t thread1, thread2; int tmp=0,rc1,rc2,num; num=atoi(argv[1]); if(num <= 3){ printf("Questo è un numero primo: %d\n", num); exit(0); } if( (rc1=pthread_create( &thread1, NULL, &num_mezzo_1, (void *)&num)) ){ printf("Creazione del thread fallita: %d\n", rc1); exit(1); } if( (rc2=pthread_create( &thread2, NULL, &num_mezzo_2, (void *)&num)) ){ printf("Creazione del thread fallita: %d\n", rc2); exit(1); } t_nums.tmp_1 = 0; t_nums.tmp_2 = 0; pthread_join(thread1, (void **)(&t_nums.tmp_1)); pthread_join(thread2, (void **)(&t_nums.tmp_2)); tmp=t_nums.tmp_1+t_nums.tmp_2; printf("%d %d %d\n", tmp, t_nums.tmp_1, t_nums.tmp_2); if(tmp>2){ printf("Questo NON è un numero primo: %d\n", num); } else{ printf("Questo è un numero primo: %d\n", num); } exit(0); } void *num_mezzo_1(void *num_orig){ int cont_1; int *n_orig=(int *)num_orig; t_nums.tmp_1 = 0; for(cont_1=1; cont_1<=(*n_orig/2); cont_1++){ if((*n_orig % cont_1) == 0){ (t_nums.tmp_1)++; } } pthread_exit((void *)(&t_nums.tmp_1)); return NULL; } void *num_mezzo_2(void *num_orig){ int cont_2; int *n_orig=(int *)num_orig; t_nums.tmp_2 = 0; for(cont_2=((*n_orig/2)+1); cont_2<=*n_orig; cont_2++){ if((*n_orig % cont_2) == 0){ (t_nums.tmp_2)++; } } pthread_exit((void *)(&t_nums.tmp_2)); return NULL; } How this program works: i have to input a number and this program will calculate if it is a prime number or not (i know that it is a bad algorithm but i only need to learn pthread). The problem is that the returned values are too much big.For example if i write "12" the value of tmp tmp_1 tmp_2 into the main are 12590412 6295204 6295208.Why i got those numbers??

    Read the article

  • Can my thread help the OS decide when to context switch it out?

    - by WilliamKF
    I am working on a threaded application on Linux in C++ which attempts to be real time, doing an action on a heartbeat, or as close to it as possible. In practice, I find the OS is swapping out my thread and causing delays of up to a tenth of a second while it is switched out, causing the heartbeat to be irregular. Is there a way my thread can hint to the OS that now is a good time to context switch it out? I could make this call right after doing a heartbeat, and thus minimize the delay due to an ill timed context switch.

    Read the article

  • C++: static function member shared between threads, can block all?

    - by mhambra
    Hi all, I have a class, which has static function defined to work with C-style extern C { static void callback(foo bar) { } }. // static is defined in header. Three objects (each in separate pthread) are instantiated from this class, each of them has own loop (in class constructor), which can receive the callback. The pointer to function is passed as: x = init_function(h, queue_id, &callback, NULL); while(1) { loop_function(x); } So each thread has the same pointer to &callback. Callback function can block for minutes. Each thread object, excluding the one which got the blocking callback, can call callback again. If the callback function exists only once, then any thread attempting to callback will also block. This would give me an undesired bug, circa is interesting to ask: can anything in C++ become acting this way? Maybe, due to extern { } or some pointer usage?

    Read the article

  • Using pthread condition variable with rwlock

    - by Doomsday
    Hello, I'm looking for a way to use pthread rwlock structure with conditions routines in C++. I have two questions: First: How is it possible and if we can't, why ? Second: Why current POSIX pthread have not implemented this behaviour ? To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing elems from the array. The benefit of using rdlock instead of mutex_lock is to improve performance: when using mutex_lock, several readers would block, whereas using rdlock several readers would not block.

    Read the article

  • Threaded application sleeps with other application

    - by DeeD
    I have a weird problem with my threaded software. I start 2 instances of the software. Each instance has 2 threads, one thread creates a socket to use, and the other one is uses the socket for communication. When one of the threads in one instance calls sleep(3), the other threads in the the other instance sleeps too. And the weirdest thing is that when I rebooted the computer, it works the first time, but after trying a second time, it sleeps like described. How is this possible? Is it using some shared resource?

    Read the article

  • Wake up thread blocked on accept() call

    - by selbie
    Sockets on Linux question I have a worker thread that is blocked on an accept() call. It simply waits for an incoming network connection, handles it, and then returns to listening for the next connection. When it is time for the program to exit, how do I signal this network worker thread (from the main thread) to return from the accept() call while still being able to gracefully exit its loop and handle it's cleanup code. Some things I tried: 1. pthread_kill to send a signal. Feels kludgy to do this, plus it doesn't reliably allow the thread to do it's shutdown logic. Also makes the program terminate as well. I'd like to avoid signals if at all possible. pthread_cancel. Same as above. It's a harsh kill on the thread. That, and the thread may be doing something else. Closing the listen socket from the main thread in order to make accept() abort. This doesn't reliably work. Some constraints: If the solution involves making the listen socket non-blocking, that is fine. But I don't want to accept a solution that involves the thread waking up via a select call every few seconds to check the exit condition. The thread condition to exit may not be tied to the process exiting. Essentially, the logic I am going for looks like this. void* WorkerThread(void* args) { DoSomeImportantInitialization(); // initialize listen socket and some thread specific stuff while (HasExitConditionBeenSet()==false) { listensize = sizeof(listenaddr); int sock = accept(listensocket, &listenaddr, &listensize); // check if exit condition has been set using thread safe semantics if (HasExitConditionBeenSet()) { break; } if (sock < 0) { printf("accept returned %d (errno==%d)\n", sock, errno); } else { HandleNewNetworkCondition(sock, &listenaddr); } } DoSomeImportantCleanup(); // close listen socket, close connections, cleanup etc.. return NULL; } void SignalHandler(int sig) { printf("Caught CTRL-C\n"); } void NotifyWorkerThreadToExit(pthread_t thread_handle) { // signal thread to exit } int main() { void* ptr_ret= NULL; pthread_t workerthread_handle = 0; pthread_create(&workerthread, NULL, WorkerThread, NULL); signal(SIGINT, SignalHandler); sleep((unsigned int)-1); // sleep until the user hits ctrl-c printf("Returned from sleep call...\n"); SetThreadExitCondition(); // sets global variable with barrier that worker thread checks on // this is the function I'm stalled on writing NotifyWorkerThreadToExit(workerthread_handle); // wait for thread to exit cleanly pthread_join(workerthread_handle, &ptr_ret); DoProcessCleanupStuff(); }

    Read the article

  • What the best multi-thread application debugger for C++ apps.

    - by Coredumped
    I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin. The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars, etc. It does not have to be an eclipse plugin or a free tool, do any of you have heard of something similar?

    Read the article

  • Another thread safe queue implementation

    - by jensph
    I have a class, Queue, that I tried to make thread safe. It has these three member variables: std::queue<T> m_queue; pthread_mutex_t m_mutex; pthread_cond_t m_condition; and a push and pop implemented as: template<class T> void Queue<T>::push(T value) { pthread_mutex_lock( &m_mutex ); m_queue.push(value); if( !m_queue.empty() ) { pthread_cond_signal( &m_condition ); } pthread_mutex_unlock( &m_mutex ); } template<class T> bool Queue<T>::pop(T& value, bool block) { bool rtn = false; pthread_mutex_lock( &m_mutex ); if( block ) { while( m_queue.empty() ) { pthread_cond_wait( &m_condition, &m_mutex ); } } if( !m_queue.empty() ) { value = m_queue.front(); m_queue.pop(); rtn = true; } pthread_mutex_unlock( &m_mutex ); return rtn; } Unfortunately there are occasional issues that may be the fault of this code. That is, there are two threads and sometimes thread 1 never comes out of push() and at other times thread 2 never comes out of pop() (the block parameter is true) though the queue isn't empty. I understand there are other implementations available, but I'd like to try to fix this code, if needed. Anyone see any issues? The constructor has the appropriate initializations: Queue() { pthread_mutex_init( &mMutex, NULL ); pthread_cond_init( &mCondition, NULL ); } and the destructor, the corresponding 'destroy' calls.

    Read the article

  • How to multi-thread this?

    - by WilliamKF
    I wish to have two threads. The first thread1 occasionally calls the following pseudo function: void waitForThread2() { if (thread2 is not idle) { return; } notifyThread2IamReady(); while (thread2IsExclusive) { } } The second thread2 is forever in the following pseudo loop: for (;;) { Notify thread1 I am idle. while (!thread1IsReady()) { } Notify thread1 I am exclusive. Do some work while thread1 is blocked. Notify thread1 I am busy. Do some work in parallel with thread1. } What is the best way to write this such that both thread1 and thread2 are kept as busy as possible on a machine with multiple cores. I would like to avoid long delays between notification in one thread and detection by the other. I tried using pthread condition variables but found the delay between thread2 doing 'notify thread1 I am busy' and the loop in waitForThread2() on thear2IsExclusive() can be up to almost one second delay. I then tried using a volatile sig_atomic_t shared variable to control the same, but something is going wrong, so I must not be doing it correctly.

    Read the article

  • How are the concepts of process and threads implementated in Linux kernel?

    - by Shan
    Can any one explain how are the concepts of process and threads implemented in Linux kernel ? I am looking for an intuitive explanation with some C snippets ( and important data structures) that clearly distinguishes between the two. I am just looking for the key implementation ideas I should get hold off. Essentially, I want to understand them and implement something similar in an embedded target (not supporte by any OS) in C language.

    Read the article

  • Thread toggling

    - by sid
    Hi all, In Ubuntu, I am running 2 'C' applications, When I press key up/down the applications are alternatively getting the events. What might be the problem/solution? Ex: I have 'A application' and 'B application', I launch 'A application' and press the key up/down its working fine. If I simultaneously launch 'B application' and focus is on 'B application' then pressing key up/down will toggle between 'A application' & 'B application' so 2 times I have to press the key to move on 'B application'(focus is on 'B application'). 'A application' and 'B application' are threads. Thanks in advance-opensid

    Read the article

  • Is PThread a good choice for multi-platorm C/C++ multi-threading program?

    - by RogerV
    Been doing mostly Java and smattering of .NET for last five years and haven't written any significant C or C++ during that time. So have been away from that scene for a while. If I want to write a C or C++ program today that does some multi-threading and is source code portable across Windows, Mac OS X, and Linux/Unix - is PThread a good choice? The C or C++ code won't be doing any GUI, so won't need to worry with any of that. For the Windows platform, I don't want to bring a lot of Unix baggage, though, in terms of unix emulation runtime libraries. Would prefer a PThread API for Windows that is a thin-as-possible wrapper over existing Windows threading APIs. ADDENDUM EDIT: Am leaning toward going with boost:thread - I also want to be able to use C++ try/catch exception handling too. And even though my program will be rather minimal and not particularly OOPish, I like to encapsulate using class and namespace - as opposed to C disembodied functions.

    Read the article

  • Pthread - setting scheduler parameters

    - by Andna
    I wanted to use read-writer locks from pthread library in a way, that writers have priority over readers. I read in my man pages that If the Thread Execution Scheduling option is supported, and the threads involved in the lock are executing with the scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not acquire the lock if a writer holds the lock or if writers of higher or equal priority are blocked on the lock; otherwise, the calling thread shall acquire the lock. so I wrote small function that sets up thread scheduling options. void thread_set_up(int _thread) { struct sched_param *_param=malloc(sizeof (struct sched_param)); int *c=malloc(sizeof(int)); *c=sched_get_priority_min(SCHED_FIFO)+1; _param->__sched_priority=*c; long *a=malloc(sizeof(long)); *a=syscall(SYS_gettid); int *b=malloc(sizeof(int)); *b=SCHED_FIFO; if (pthread_setschedparam(*a,*b,_param) == -1) { //depending on which thread calls this functions, few thing can happen if (_thread == MAIN_THREAD) client_cleanup(); else if (_thread==ACCEPT_THREAD) { pthread_kill(params.main_thread_id,SIGINT); pthread_exit(NULL); } } } sorry for those a,b,c but I tried to malloc everything, still I get SIGSEGV on the call to pthread_setschedparam, I am wondering why?

    Read the article

  • Is pthread_spin_trylock safe inside of sigsegv handler of multithreaded application?

    - by TWMouton
    I am trying to implement a handler that on SIGSEGV will collect some information such as process-id, thread-id and a backtrace and write this information to a file/pipe/socket. The problem lies in that there is the (probably pretty high) possibility that if one thread experienced a SIGSEGV that the others will shortly follow. If two threads happen to make it to the bit of code where they're writing their report out at the same time then they'll interleave their writing (to the same file). I know that I should only be using async-signal-safe functions as detailed in signal(7) I also have seen at least two cases here and video linked in top answer here where others have used pthread_spin_trylock to get around this problem. Is this a safe way to prevent the above problem?

    Read the article

  • pthread_exit return value

    - by Manty
    This is surprising for me. void * thread_func(void *arg) { pthread_exit(&ret); } int main(void) { pthread_t thr; int *exit_status; pthread_create(&thr, NULL, thread_func, NULL); sleep(2); pthread_join(thr, (void **)&exit_status); printf("value of exit status - %d\n", *exit_status); ret = 20; pthread_join(thr, (void **)&exit_status); printf("value of exit status - %d\n", *exit_status); return 0; } The output is value of exit status - 50 value of exit status - 20 I was expecting both the times the exit_status would be the actual exit value(50 in my case) of the thread. Instead it is just returning the value of the global variable which I used for pthread_exit. Is it not a bug?

    Read the article

  • How should a multi-threaded C application handle a failed malloc()?

    - by user294463
    A part of an application I'm working on is a simple pthread-based server that communicates over a TCP/IP socket. I am writing it in C because it's going to be running in a memory constrained environment. My question is: what should the program do if one of the threads encounters a malloc() that returns NULL? Possibilities I've come up with so far: No special handling. Let malloc() return NULL and let it be dereferenced so that the whole thing segfaults. Exit immediately on a failed malloc(), by calling abort() or exit(-1). Assume that the environment will clean everything up. Jump out of the main event loop and attempt to pthread_join() all the threads, then shut down. The first option is obviously the easiest, but seems very wrong. The second one also seems wrong since I don't know exactly what will happen. The third option seems tempting except for two issues: first, all of the threads need not be joined back to the main thread under normal circumstances and second, in order to complete the thread execution, most of the remaining threads will have to call malloc() again anyway. What shall I do?

    Read the article

  • how to print correctly the handling thread on Windows?

    - by make
    Hi, Could someone please tell us on how to print correctly the handling thread in windows? Actually I tried several ways but it doesn't return the right number as in Unix-variant, as such e.g.: cout << " with thread " << pthread_self << endl; cout << " with thread " << pthread_self().p << endl; Thanks for your replies:

    Read the article

  • Why thread specific data is required in pthread ?

    - by user504542
    Hi As i know, all the threads share memory location. For example a global variable changes in one thread will reflect in another thread. Since each thread has its own stack, the local variables that are created inside the thread is unique. In this case, why do we need to go for thread specific data mechanism?. Can't it be achieved by auto storage varibles inside the thread function ? Kindly clarify!!!. BR Rj

    Read the article

  • How do I use ffmpeg to take pictures with my web camera?

    - by user45583
    I want to use ffmpeg to store images taken by my USB web camera on my Ubuntu 11.10. lsusb outputs: Bus 002 Device 003: ID 0c45:6028 Microdia Typhoon Easycam USB 330K (older) The camera works fine using cheese but I want to use command line tools to make it scriptable but if I try: ffmpeg -i /dev/v4l/by-id/usb-0c45_USB_camera-video-index0 image.jpg The output is: user@box:~$ sudo ffmpeg -i /dev/v4l/by-id/usb-0c45_USB_camera-video-index0 image.jpg [sudo] password for user: ffmpeg version 0.7.3-4:0.7.3-0ubuntu0.11.10.1, Copyright (c) 2000-2011 the Libav developers built on Jan 4 2012 16:21:50 with gcc 4.6.1 configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static WARNING: library configuration mismatch avutil configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay avcodec configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay avformat configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay avdevice configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay avfilter configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay swscale configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay postproc configuration: --extra-version='4:0.7.3-0ubuntu0.11.10.1' --arch=i386 --prefix=/usr --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-vaapi --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --shlibdir=/usr/lib/i686/cmov --cpu=i686 --enable-shared --disable-static --disable-ffmpeg --disable-ffplay libavutil 51. 7. 0 / 51. 7. 0 libavcodec 53. 6. 0 / 53. 6. 0 libavformat 53. 3. 0 / 53. 3. 0 libavdevice 53. 0. 0 / 53. 0. 0 libavfilter 2. 4. 0 / 2. 4. 0 libswscale 2. 0. 0 / 2. 0. 0 libpostproc 52. 0. 0 / 52. 0. 0 /dev/v4l/by-id/usb-0c45_USB_camera-video-index0: Invalid data found when processing input How do I make this work?

    Read the article

  • How to safely operate on parameters in threads, using C++ & Pthreads?

    - by ChrisCphDK
    Hi. I'm having some trouble with a program using pthreads, where occassional crashes occur, that could be related to how the threads operate on data So I have some basic questions about how to program using threads, and memory layout: Assume that a public class function performs some operations on some strings, and returns the result as a string. The prototype of the function could be like this: std::string SomeClass::somefunc(const std::string &strOne, const std::string &strTwo) { //Error checking of strings have been omitted std::string result = strOne.substr(0,5) + strTwo.substr(0,5); return result; } Is it correct to assume that strings, being dynamic, are stored on the heap, but that a reference to the string is allocated on the stack at runtime? Stack: [Some mem addr] pointer address to where the string is on the heap Heap: [Some mem addr] memory allocated for the initial string which may grow or shrink To make the function thread safe, the function is extended with the following mutex (which is declared as private in the "SomeClass") locking: std::string SomeClass::somefunc(const std::string &strOne, const std::string &strTwo) { pthread_mutex_lock(&someclasslock); //Error checking of strings have been omitted std::string result = strOne.substr(0,5) + strTwo.substr(0,5); pthread_mutex_unlock(&someclasslock); return result; } Is this a safe way of locking down the operations being done on the strings (all three), or could a thread be stopped by the scheduler in the following cases, which I'd assume would mess up the intended logic: a. Right after the function is called, and the parameters: strOne & strTwo have been set in the two reference pointers that the function has on the stack, the scheduler takes away processing time for the thread and lets a new thread in, which overwrites the reference pointers to the function, which then again gets stopped by the scheduler, letting the first thread back in? b. Can the same occur with the "result" string: the first string builds the result, unlocks the mutex, but before returning the scheduler lets in another thread which performs all of it's work, overwriting the result etc. Or are the reference parameters / result string being pushed onto the stack while another thread is doing performing it's task? Is the safe / correct way of doing this in threads, and "returning" a result, to pass a reference to a string that will be filled with the result instead: void SomeClass::somefunc(const std::string &strOne, const std::string &strTwo, std::string result) { pthread_mutex_lock(&someclasslock); //Error checking of strings have been omitted result = strOne.substr(0,5) + strTwo.substr(0,5); pthread_mutex_unlock(&someclasslock); } The intended logic is that several objects of the "SomeClass" class creates new threads and passes objects of themselves as parameters, and then calls the function: "someFunc": int SomeClass::startNewThread() { pthread_attr_t attr; pthread_t pThreadID; if(pthread_attr_init(&attr) != 0) return -1; if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0) return -2; if(pthread_create(&pThreadID, &attr, proxyThreadFunc, this) != 0) return -3; if(pthread_attr_destroy(&attr) != 0) return -4; return 0; } void* proxyThreadFunc(void* someClassObjPtr) { return static_cast<SomeClass*> (someClassObjPtr)->somefunc("long string","long string"); } Sorry for the long description. But I hope the questions and intended purpose is clear, if not let me know and I'll elaborate. Best regards. Chris

    Read the article

  • How this pthread actually works?

    - by user289013
    I am actually on my project on compiler with SMP, and want to code with pthreads and heard about many parallel things open mpi and so on, So to start with how this thread is allocated to core while calling pthread,Is there any way to give threads to different cores by pthreads?

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >