Sponsored Content
Full Discussion: pthread_create problem
Top Forums Programming pthread_create problem Post 62309 by Neo on Monday 14th of February 2005 10:35:24 PM
Old 02-14-2005
Quote:
Originally Posted by Perderabo
Oh, Neo! I hope you're sitting down!

I was using Microsoft's SFU running on Windows XP! Smilie
.
Perderabo,

I'm shocked! Smilie

Neo

(heading to the wine cellar for a drink!)
 

9 More Discussions You Might Find Interesting

1. Programming

unresolve pthread_create etc

how to do with that? after cc -o xxxx xxxx.c ld: Unresolved: _pthread_create _pthread_deteach _pthread_exit Thanks (3 Replies)
Discussion started by: zhshqzyc
3 Replies

2. Programming

Pthread_create issue

Hello My problem goes like this: I have used Pthread_create, and I have tryed to create 2 proccess but nothing happens! It does not even matter what the function im trying to create do. It is if im trying to activate an empty function. This is my code. Any help will be highly appreciated.... (1 Reply)
Discussion started by: Hellboy
1 Replies

3. Programming

How Can I use pthread_create ?

Hi. I use C++ and I wishes to create a thread with the pthread_create function, my question is, how can I do this if I wish that the function will be a member of the class ?? I know from windows programming that I can declare a static function like this static unsigned int __stdcall... (7 Replies)
Discussion started by: shvalb
7 Replies

4. Linux

problem in Passing arguements to pthread_create

Hello every one My question may look very easy, sorry for my ignorance. I am not able to figure the problem. #include<stdio.h> #include<stdlib.h> #include<pthread.h> void *myfunc(void *vptr_value) { int value = *((int *)vptr_value); printf("Thread value: %d \n", value); ... (1 Reply)
Discussion started by: praveenpvs
1 Replies

5. Solaris

pthread_create failed upon execution

Im trying to run an application i compiled (iperf) and i get an error telling me that it cant create the pthread. when i ran the ./configuration one of the things it checked was for pthreads which came back ok. Im not really sure where to even start to resolve this. i have been unable to find... (5 Replies)
Discussion started by: jrich523
5 Replies

6. Programming

undefined reference to pthread_create

I try to compile a sample c code in fedora eclipse 3.2 as managed makefile using pthread library,it shows some error on pthread functions.Error is of undefined reference to pthread.Anybody guide me to solve this problem. Thanking you (1 Reply)
Discussion started by: sujith4u87
1 Replies

7. Programming

pthread_create

The prototype for pthread_create function is like this:- int pthread_create(pthread_t *thread,pthread_attr_t *attr,void *(*start routine),void *arg); Q.1 .Why the return type of the start_routine must be void*?? Q.2. Why should we pass arg by converting into void * only ?? Thank You (3 Replies)
Discussion started by: sunil_abhay
3 Replies

8. UNIX for Dummies Questions & Answers

Pthread_create problem

Hi, I'm trying to do my homework assignment but I am having trouble using the pthread_create fucntion. Here is my code________________ //Alicia Johnson //sum_pid program //creates n number of threads. These threads create a random number //then adds the number to a global array. Then... (1 Reply)
Discussion started by: ajohns38
1 Replies

9. Programming

fork vs pthread_create

Suppose I have a simple program main() with a global varibale int x=0. int x = 0; main() { print("%d\n",x); } I want to create two threads/process which must access this variable x in sync. Which one will be better threads( pthread_create ) or process( fork )? If I go with fork() then... (1 Reply)
Discussion started by: rupeshkp728
1 Replies
sigwait(2)							   System Calls 							sigwait(2)

NAME
sigwait - wait until a signal is posted SYNOPSIS
#include <signal.h> int sigwait(sigset_t *set); Standard conforming cc [ flag ... ] file ... -D_POSIX_PTHREAD_SEMANTICS [ library...] #include <signal.h> int sigwait(const sigset_t *set, int *sig); DESCRIPTION
The sigwait() function selects a signal in set that is pending on the calling thread (see thr_create(3C) and pthread_create(3C).) If no signal in set is pending, sigwait() blocks until a signal in set becomes pending. The selected signal is cleared from the set of signals pending on the calling thread and the number of the signal is returned, or in the standard-conforming version (see standards(5)) placed in sig. The selection of a signal in set is independent of the signal mask of the calling thread. This means a thread can synchronously wait for signals that are being blocked by the signal mask of the calling thread . To ensure that only the caller receives the signals defined in set, all threads should have signals in set masked including the calling thread. If the set argument points to an invalid address, the behavior is undefined and errno may be set to EFAULT. If sigwait() is called on an ignored signal, then the occurrence of the signal will be ignored, unless sigaction() changes the disposition. If more than one thread waits for the same signal, only one is unblocked when the signal arrives. RETURN VALUES
Upon successful completion, the default version of sigwait() returns a signal number; the standard-conforming version returns 0 and stores the received signal number at the location pointed to by sig. Otherwise, -1 is returned and errno is set to indicate an error. ERRORS
The sigwait() function will fail if: EINTR The wait was interrupted by an unblocked, caught signal. EINVAL The set argument contains an unsupported signal number. The sigwait() function may fail if: EFAULT The set argument points to an invalid address. EXAMPLES
Example 1 Creating a thread to handle receipt of a signal The following sample C code creates a thread to handle the receipt of a signal. More specifically, it catches the asynchronously generated signal, SIGINT. /******************************************************************** * * compile with -D_POSIX_PTHREAD_SEMANTICS switch; * required by sigwait() * * sigint thread handles delivery of signal. uses sigwait() to wait * for SIGINT signal. * ********************************************************************/ #include <pthread.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <synch.h> static void *threadTwo(void *); static void *threadThree(void *); static void *sigint(void *); sigset_t signalSet; void * main(void) { pthread_t t; pthread_t t2; pthread_t t3; sigfillset ( &signalSet ); /* * Block signals in initial thread. New threads will * inherit this signal mask. */ pthread_sigmask ( SIG_BLOCK, &signalSet, NULL ); printf("Creating threads "); pthread_create(&t, NULL, sigint, NULL); pthread_create(&t2, NULL, threadTwo, NULL); pthread_create(&t3, NULL, threadThree, NULL); printf("################## "); printf("press CTRL-C to deliver SIGINT to sigint thread "); printf("################## "); pthread_exit((void *)0); } static void * threadTwo(void *arg) { printf("hello world, from threadTwo [tid: %d] ", pthread_self()); printf("threadTwo [tid: %d] is now complete and exiting ", pthread_self()); pthread_exit((void *)0); } static void * threadThree(void *arg) { printf("hello world, from threadThree [tid: %d] ", pthread_self()); printf("threadThree [tid: %d] is now complete and exiting ", pthread_self()); pthread_exit((void *)0); } void * sigint(void *arg) { int sig; int err; printf("thread sigint [tid: %d] awaiting SIGINT ", pthread_self()); /* /* use standard-conforming sigwait() -- 2 args: signal set, signum */ err = sigwait ( &signalSet, &sig ); /* test for SIGINT; could catch other signals */ if (err || sig != SIGINT) abort(); printf(" SIGINT signal %d caught by sigint thread [tid: %d] ", sig, pthread_self()); pthread_exit((void *)0); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
sigaction(2), signal.h(3HEAD), sigpending(2), sigprocmask(2), sigsuspend(2), pthread_create(3C), pthread_sigmask(3C), thr_create(3C), thr_sigsetmask(3C), attributes(5), standards(5) NOTES
The sigwait() function cannot be used to wait for signals that cannot be caught (see sigaction(2)). This restriction is silently imposed by the system. Solaris 2.4 and earlier releases provided a sigwait() facility as specified in POSIX.1c Draft 6. The final POSIX.1c standard changed the interface as described above. Support for the Draft 6 interface is provided for compatibility only and may not be supported in future releases. New applications and libraries should use the standard-conforming interface. SunOS 5.11 24 Jun 2002 sigwait(2)
All times are GMT -4. The time now is 11:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy