Sponsored Content
Full Discussion: thread pool problem
Top Forums UNIX for Dummies Questions & Answers thread pool problem Post 302482523 by jim mcnamara on Tuesday 21st of December 2010 08:34:26 PM
Old 12-21-2010
pthread_create has a void* argument for passing values.
create a struct that has as many arguments as you want, pass that.
Code:
typedef struct
{
   char string[64];
   double  dbl;
   int  intarg;
} my args_t;
// ...............
args_t myargs;
pthread_t tid;
myargs.dbl=32.3;
strcpy(myargs, "some string value");
myargs.intarg=42;
pthread_create(&tid, foo, NULL< &myargs);

in function foo()
Code:
foo(void *args)
{
     myargs_t *arg=(myargs_t *) args;
     printf("%d\n", arg->intarg); 
}

This User Gave Thanks to jim mcnamara For This Post:
 

8 More Discussions You Might Find Interesting

1. Programming

Question on creation of Thread pool

dear sir/madam presently i am in a process of creating a multithread pool using clone() system call in unix with c programming. i am facing some problem ie., i am able create multithread pool and able to keep all the threads in wait state,but when i call kill (afunction revoke a... (6 Replies)
Discussion started by: Radha
6 Replies

2. UNIX for Advanced & Expert Users

Thread synchronisation problem...

Hello, hope my english will be sufficient to be clear enough... I'm in progress on some script that should copy one big source file (200GB average) on one sata drive, to multiple (30+) sata drives. Hardware is not the problem but copy performance is... If i launch all copy process at the same... (4 Replies)
Discussion started by: Gnaag
4 Replies

3. AIX

HMC & Processor Pool problem

Hi, I am having problem allocating all my processors -- 6 processors -- to sharedpool1 I have 6 processors and I want my lpars to share all these 6 processors. DefaultPool can't be edited. I edit my Sharedpool1 as follows Reserved:0 Max Processors: 6 In my lpar profile: Min: 1... (1 Reply)
Discussion started by: filosophizer
1 Replies

4. Post Here to Contact Site Administrators and Moderators

posting thread is problem

hi, i am unable to post new thread. pls revert back what i need to do. i already posted 3 threads.... I am getting message like " Message is too short" even though my message is more than 100 characters. (1 Reply)
Discussion started by: spc432
1 Replies

5. Infrastructure Monitoring

zfs - migrate from pool to pool

Here are the details. cnjr-opennms>root$ zfs list NAME USED AVAIL REFER MOUNTPOINT openpool 20.6G 46.3G 35.5K /openpool openpool/ROOT 15.4G 46.3G 18K legacy openpool/ROOT/rds 15.4G 46.3G 15.3G / openpool/ROOT/rds/var 102M ... (3 Replies)
Discussion started by: pupp
3 Replies

6. Solaris

Problem with pool Service

hi all, i am trying to enable pool service but i recive this message -bash-3.00# pooladm pooladm: couldn't open pools state file: Facility is not active -bash-3.00# pooladm -e svcadm: Instance "svc:/system/pools:default" is in maintenance state. pooladm: cannot enable pools:... (4 Replies)
Discussion started by: corvinusbsd
4 Replies

7. Programming

Multi thread data sharing problem in uclinux

hello, I have wrote a multi thread application to run under uclinux. the problem is that threads does not share data. using the ps command it shows a single process for each thread. I test the application under Ubuntu 8.04 and Open Suse 10.3 with 2.6 kernel and there were no problems and also... (8 Replies)
Discussion started by: mrhosseini
8 Replies

8. Forum Support Area for Unregistered Users & Account Problems

I am still meet a problem when I want to reply or create a new thread

Hi, Scott, I am still meet a problem when I want to reply or create a new thread in "Shell Programming and Scripting" Forum, It reminds that: To create new threads in this forum your post count must be 10 or greater. You currently have 2 posts. To my surprise, I posted a thread in "Shell... (4 Replies)
Discussion started by: weichanghe2000
4 Replies
door_bind(3DOOR)					      Door Library Functions						  door_bind(3DOOR)

NAME
door_bind, door_unbind - bind or unbind the current thread with the door server pool SYNOPSIS
cc -mt [ flag... ] file... -ldoor [ library... ] #include <door.h> int door_bind(int did); int door_unbind(void); DESCRIPTION
The door_bind() function associates the current thread with a door server pool. A door server pool is a private pool of server threads that is available to serve door invocations associated with the door did. The door_unbind() function breaks the association of door_bind() by removing any private door pool binding that is associated with the cur- rent thread. Normally, door server threads are placed in a global pool of available threads that invocations on any door can use to dispatch a door invocation. A door that has been created with DOOR_PRIVATE only uses server threads that have been associated with the door by door_bind(). It is therefore necessary to bind at least one server thread to doors created with DOOR_PRIVATE. The server thread create function, door_server_create(), is initially called by the system during a door_create() operation. See door_server_create(3DOOR) and door_create(3DOOR). The current thread is added to the private pool of server threads associated with a door during the next door_return() (that has been issued by the current thread after an associated door_bind()). See door_return(3DOOR). A server thread performing a door_bind() on a door that is already bound to a different door performs an implicit door_unbind() of the previous door. If a process containing threads that have been bound to a door calls fork(2), the threads in the child process will be bound to an invalid door, and any calls to door_return(3DOOR) will result in an error. RETURN VALUES
Upon successful completion, a 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The door_bind() and door_unbind() functions fail if: EBADF The did argument is not a valid door. EBADF The door_unbind() function was called by a thread that is currently not bound. EINVAL did was not created with the DOOR_PRIVATE attribute. EXAMPLES
Example 1: Use door_bind() to create private server pools for two doors. The following example shows the use of door_bind() to create private server pools for two doors, d1 and d2. Function my_create() is called when a new server thread is needed; it creates a thread running function, my_server_create(), which binds itself to one of the two doors. #include <door.h> #include <thread.h> #include <pthread.h> thread_key_t door_key; int d1 = -1; int d2 = -1; cond_t cv; /* statically initialized to zero */ mutex_t lock; /* statically initialized to zero */ extern void foo(void *, char *, size_t, door_desc_t *, uint_t); extern void bar(void *, char *, size_t, door_desc_t *, uint_t); static void * my_server_create(void *arg) { /* wait for d1 & d2 to be initialized */ mutex_lock(&lock); while (d1 == -1 || d2 == -1) cond_wait(&cv, &lock); mutex_unlock(&lock); if (arg == (void *)foo){ /* bind thread with pool associated with d1 */ thr_setspecific(door_key, (void *)foo); if (door_bind(d1) < 0) { perror("door_bind"); exit (-1); } } else if (arg == (void *)bar) { /* bind thread with pool associated with d2 */ thr_setspecific(door_key, (void *)bar); if (door_bind(d2) < 0) { /* bind thread to d2 thread pool */ perror("door_bind"); exit (-1); } } pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); door_return(NULL, 0, NULL, 0); /* Wait for door invocation */ } static void my_create(door_info_t *dip) { /* Pass the door identity information to create function */ thr_create(NULL, 0, my_server_create, (void *)dip->di_proc, THR_BOUND | THR_DETACHED, NULL); } main() { (void) door_server_create(my_create); if (thr_keycreate(&door_key, NULL) != 0) { perror("thr_keycreate"); exit(1); } mutex_lock(&lock); d1 = door_create(foo, NULL, DOOR_PRIVATE); /* Private pool */ d2 = door_create(bar, NULL, DOOR_PRIVATE); /* Private pool */ cond_signal(&cv); mutex_unlock(&lock); while(1) pause(); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |all | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
fork(2),door_create(3DOOR), door_return(3DOOR), door_server_create(3DOOR), libdoor(3LIB), attributes(5) SunOS 5.10 23 Apr 2003 door_bind(3DOOR)
All times are GMT -4. The time now is 06:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy