[Hamlib-developer] threaded thoughts !!
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: Frank S. <vk...@ix...> - 2000-11-28 00:40:37
|
Stephane Fillod wrote:
> > --- ft747.c 2000/11/25 21:49:34 1.21
> > *
> > ! * 1. Rentrant code, handle static stuff <--- ie: get rid of this stuff
> > * 2. rationalise code, more helper functions.
> >
> > --- 262,317 ----
> >
> > int ft747_set_freq(RIG *rig, freq_t freq) {
> > + struct rig_state *rig_s;
> > + struct ft747_priv_data *p;
> > +
> > + static unsigned char bcd[] = { 0,0,0,0 }; /* set freq */
>
> static local variables (kindof "restricted" global variables) were
> not well suited for reentrant code. And the p_cmd are not either, since
> the struct would be shared in the data section. Most of the time,
> reentrant mutexless solutions would make use of variables on the stack
> (eventually alloca) or dynamic memory allocated on a per thread basis.
> Anyway, reentrancy is not the primary focus right now :)
True, as my comments suggest, I need to handle this static
stuff properly. ie: Remove it.
Can we not have instance data in priv_ and mutex locks
on API function level.
eg:
pthread_mutex_lock(&shared.mutex);
....do stuff
pthread_mutex_unlock(&shared.mutex);
Do we consider function call level (eg: rig_set..() ) the right
size of thread "granularity" ?
Its probably a good starting point.
Anyway, not an immediate problem, but
something to think about :-()
/Frank :-)
> _______________________________________________
> Hamlib-developer mailing list
> Ham...@li...
> http://lists.sourceforge.net/mailman/listinfo/hamlib-developer
|