OpenQNX :: The QNX Community Portal

May 13, 2008 - 10:36 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 67 unlogged users and 1 registered user online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
thuongshoo
Post subject: What does thread_pool_start actually do?  PostPosted: Mar 27, 2008 - 10:15 AM
Active Member


Joined: Feb 20, 2008
Posts: 12

Hi!Smile
I have just run a multi-threaded device resource manager but perhaps there is a mysterious Neutral
I want to know what thread_pool_start actually does.
I'm sorry! I increased font size to be easy to view.


Code:

thread_pool_attr_t   pool_attr;
.......................................
pool_attr.handle = dpp;
    pool_attr.context_alloc = (void*)dispatch_context_alloc;
    pool_attr.block_func =(void*)dispatch_block;
    pool_attr.unblock_func =(void*)dispatch_unblock;
    pool_attr.handler_func =  (void*)dispatch_handler;
    pool_attr.context_free = (void*) dispatch_context_free;


I guess:
-At the first, dispatch_context_alloc is called and it need a dispatch_t argument . This argument is pool_attr.handle
- and then, thread_pool_start calls dispatch_block but this function needs a dispatch_context_t argument. But I don't know what will be used as a argument for this funciton.
- and the same question for dispatch_unblock, dispatch_handler
I viewed fields of thread_pool_attr_. This structure has not any dispatch_context_t field



Code:
#ifndef THREAD_POOL_PARAM_T
 #define THREAD_POOL_PARAM_T   void
#endif

#ifndef THREAD_POOL_HANDLE_T
 #define THREAD_POOL_HANDLE_T   dispatch_t
#endif

typedef struct _thread_pool_attr {
   THREAD_POOL_HANDLE_T   *handle;
   THREAD_POOL_PARAM_T      *(*block_func)(THREAD_POOL_PARAM_T *ctp);
   void               (*unblock_func)(THREAD_POOL_PARAM_T *ctp);
   int                  (*handler_func)(THREAD_POOL_PARAM_T *ctp);
   THREAD_POOL_PARAM_T      *(*context_alloc)(THREAD_POOL_HANDLE_T *handle);
   void               (*context_free)(THREAD_POOL_PARAM_T *ctp);
   pthread_attr_t         *attr;
   unsigned short         lo_water;
   unsigned short         increment;
   unsigned short         hi_water;
   unsigned short         maximum;
   unsigned            reserved[8];
} thread_pool_attr_t;


The only field which can be used is pthread_attr_t *attr;
And this is fields of the structure:


Code:
#if defined(__PTHREAD_ATTR_T)
typedef __PTHREAD_ATTR_T   pthread_attr_t;
#undef __PTHREAD_ATTR_T
#endif



Code:
#define __PTHREAD_ATTR_T \
   struct _thread_attr { \
      int                     flags; \
      _Sizet                  stacksize; \
      void                  *stackaddr; \
      void                  (*exitfunc)(void *status); \
      int                     policy; \
      struct sched_param         param; \
      unsigned               guardsize; \
      unsigned               prealloc; \
      int                     spare[2]; \
   }


Code:
dispatch_context_t       *dispatch_context_alloc(dispatch_t *dpp);
dispatch_context_t       *dispatch_block(dispatch_context_t *ctp);
void               dispatch_unblock(dispatch_context_t *ctp);
int                dispatch_handler(dispatch_context_t *ctp);
void               dispatch_context_free(dispatch_context_t *ctp);
 
 View user's profile Send private message  
Reply with quote Back to top
rgallen
Post subject: Re: What does thread_pool_start actually do?  PostPosted: Mar 27, 2008 - 04:00 PM
QNX Master


Joined: Jul 11, 2002
Posts: 557

thuongshoo wrote:
Hi!Smile
I want to know what thread_pool_start actually does.


No need to speculate, the source code is here...

http://community.qnx.com/integration/viewcvs/viewcvs.cgi/trunk/lib/c/?root=coreos_pub&system=exsy1001
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
thuongshoo
Post subject: RE: Re: What does thread_pool_start actually do?  PostPosted: Mar 28, 2008 - 09:11 AM
Active Member


Joined: Feb 20, 2008
Posts: 12

Thanks rgallen! Smile
It is not simple Very Happy
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.