unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Critical section review
@ 2005-03-23  8:16 Neil Jerram
  2005-03-23  8:58 ` Mikael Djurfeldt
  2005-03-23  9:02 ` Mikael Djurfeldt
  0 siblings, 2 replies; 8+ messages in thread
From: Neil Jerram @ 2005-03-23  8:16 UTC (permalink / raw)


OK, to get the ball rolling and fill in my understanding: 
scm_make_memoized() in debug.c has:

   SCM_CRITICAL_SECTION_START;
   SCM_NEWSMOB (z, SCM_UNPACK (exp), SCM_UNPACK (env));
   SCM_NEWSMOB (ans, scm_tc16_memoized, SCM_UNPACK (z));
   SCM_CRITICAL_SECTION_END;

So:

- why do we need a critical section here?

- given that there is a critical section here, isn't there a problem 
that one of the SCM_NEWSMOBs could throw a memory error?

(I have read what it says in the manual on critical sections, by the way.)

Regards,
	Neil


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23  8:16 Critical section review Neil Jerram
@ 2005-03-23  8:58 ` Mikael Djurfeldt
  2005-03-23  9:02 ` Mikael Djurfeldt
  1 sibling, 0 replies; 8+ messages in thread
From: Mikael Djurfeldt @ 2005-03-23  8:58 UTC (permalink / raw)
  Cc: guile-devel

On Wed, 23 Mar 2005 08:16:00 +0000, Neil Jerram <neil@ossau.uklinux.net> wrote:
> OK, to get the ball rolling and fill in my understanding:
> scm_make_memoized() in debug.c has:
> 
>    SCM_CRITICAL_SECTION_START;
>    SCM_NEWSMOB (z, SCM_UNPACK (exp), SCM_UNPACK (env));
>    SCM_NEWSMOB (ans, scm_tc16_memoized, SCM_UNPACK (z));
>    SCM_CRITICAL_SECTION_END;
> 
> So:
> 
> - why do we need a critical section here?

We don't.

The above code is the result of multiple applications of query-replace
during several years of GUile development. All four lines should be
replaced by a call to SCM_RETURN_NEWSMOB.

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23  8:16 Critical section review Neil Jerram
  2005-03-23  8:58 ` Mikael Djurfeldt
@ 2005-03-23  9:02 ` Mikael Djurfeldt
  2005-03-23 20:19   ` Neil Jerram
  1 sibling, 1 reply; 8+ messages in thread
From: Mikael Djurfeldt @ 2005-03-23  9:02 UTC (permalink / raw)
  Cc: guile-devel

On Wed, 23 Mar 2005 08:16:00 +0000, Neil Jerram <neil@ossau.uklinux.net> wrote:
> OK, to get the ball rolling and fill in my understanding:
> scm_make_memoized() in debug.c has:
> 
>    SCM_CRITICAL_SECTION_START;
>    SCM_NEWSMOB (z, SCM_UNPACK (exp), SCM_UNPACK (env));
>    SCM_NEWSMOB (ans, scm_tc16_memoized, SCM_UNPACK (z));
>    SCM_CRITICAL_SECTION_END;

In addition, the first call to SCM_NEWSMOB is obviously bogus. It
should be a call to scm_cons.

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23  9:02 ` Mikael Djurfeldt
@ 2005-03-23 20:19   ` Neil Jerram
  2005-03-23 20:35     ` Mikael Djurfeldt
  2005-03-23 21:34     ` Marius Vollmer
  0 siblings, 2 replies; 8+ messages in thread
From: Neil Jerram @ 2005-03-23 20:19 UTC (permalink / raw)
  Cc: djurfeldt

Mikael Djurfeldt wrote:
> On Wed, 23 Mar 2005 08:16:00 +0000, Neil Jerram <neil@ossau.uklinux.net> wrote:
> 
>>OK, to get the ball rolling and fill in my understanding:
>>scm_make_memoized() in debug.c has:
>>
>>   SCM_CRITICAL_SECTION_START;
>>   SCM_NEWSMOB (z, SCM_UNPACK (exp), SCM_UNPACK (env));
>>   SCM_NEWSMOB (ans, scm_tc16_memoized, SCM_UNPACK (z));
>>   SCM_CRITICAL_SECTION_END;
> 
> 
> In addition, the first call to SCM_NEWSMOB is obviously bogus. It
> should be a call to scm_cons.

Thanks.  So this is now just:
   SCM_RETURN_NEWSMOB (scm_tc16_memoized, scm_cons (exp, env));

which is a completely mechanical change except that one SCM_UNPACK(...) 
has become ((scm_t_bits) ...) - is the definition of SCM_NEWSMOB correct 
in using (scm_t_bits) rather than SCM_UNPACK ?

	Neil


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23 20:19   ` Neil Jerram
@ 2005-03-23 20:35     ` Mikael Djurfeldt
  2005-03-23 21:34     ` Marius Vollmer
  1 sibling, 0 replies; 8+ messages in thread
From: Mikael Djurfeldt @ 2005-03-23 20:35 UTC (permalink / raw)
  Cc: guile-devel

On Wed, 23 Mar 2005 20:19:22 +0000, Neil Jerram <neil@ossau.uklinux.net> wrote:
> So this is now just:
>    SCM_RETURN_NEWSMOB (scm_tc16_memoized, scm_cons (exp, env));
> 
> which is a completely mechanical change except that one SCM_UNPACK(...)
> has become ((scm_t_bits) ...) - is the definition of SCM_NEWSMOB correct
> in using (scm_t_bits) rather than SCM_UNPACK ?

Well,I guess so. I'm no SCM_PACK/SCM_UNPACK expert.

M


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23 20:19   ` Neil Jerram
  2005-03-23 20:35     ` Mikael Djurfeldt
@ 2005-03-23 21:34     ` Marius Vollmer
  2005-03-24  7:30       ` Neil Jerram
  1 sibling, 1 reply; 8+ messages in thread
From: Marius Vollmer @ 2005-03-23 21:34 UTC (permalink / raw)
  Cc: djurfeldt, guile-devel

Neil Jerram <neil@ossau.uklinux.net> writes:

> Thanks.  So this is now just:
>    SCM_RETURN_NEWSMOB (scm_tc16_memoized, scm_cons (exp, env));
>
> which is a completely mechanical change except that one
> SCM_UNPACK(...) has become ((scm_t_bits) ...) - is the definition of
> SCM_NEWSMOB correct in using (scm_t_bits) rather than SCM_UNPACK ?

The definition of SCM_NEWSMOB is correct; its prototype is

  SCM SCM_NEWSMOB (scm_t_bits tag, scm_t_bits data);

However, if you want to use a SCM value as the data of a smob, you
need to use SCM_UNPACK to convert that SCM into a scm_t_bits:

  SCM_RETURN_NEWSMOB (scm_tc16_memoized, SCM_UNPACK (scm_cons (exp, env)));

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-23 21:34     ` Marius Vollmer
@ 2005-03-24  7:30       ` Neil Jerram
  2005-03-30 18:46         ` Neil Jerram
  0 siblings, 1 reply; 8+ messages in thread
From: Neil Jerram @ 2005-03-24  7:30 UTC (permalink / raw)
  Cc: djurfeldt, guile-devel

Marius Vollmer wrote:
> 
> The definition of SCM_NEWSMOB is correct; its prototype is
> 
>   SCM SCM_NEWSMOB (scm_t_bits tag, scm_t_bits data);

In this case, why does the implementation of SCM_NEWSMOB need a cast? 
Surely this cast is likely to hide bad uses of SCM_NEWSMOB.

> 
> However, if you want to use a SCM value as the data of a smob, you
> need to use SCM_UNPACK to convert that SCM into a scm_t_bits:
> 
>   SCM_RETURN_NEWSMOB (scm_tc16_memoized, SCM_UNPACK (scm_cons (exp, env)));

OK, I've done this now, although I think it would be more convenient to 
move the SCM_UNPACK into the definition of SCM_RETURN_NEWSMOB.

	Neil


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Critical section review
  2005-03-24  7:30       ` Neil Jerram
@ 2005-03-30 18:46         ` Neil Jerram
  0 siblings, 0 replies; 8+ messages in thread
From: Neil Jerram @ 2005-03-30 18:46 UTC (permalink / raw)
  Cc: guile-devel


FYI, I've committed some review comments to eval.c and dynl.c (having 
skipped deprecated.c for now on the grounds that it's less important). 
You can find them by grepping for "njrev".

(Obviously, feel free to change or remove them after consideration.)

	Neil


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-30 18:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-23  8:16 Critical section review Neil Jerram
2005-03-23  8:58 ` Mikael Djurfeldt
2005-03-23  9:02 ` Mikael Djurfeldt
2005-03-23 20:19   ` Neil Jerram
2005-03-23 20:35     ` Mikael Djurfeldt
2005-03-23 21:34     ` Marius Vollmer
2005-03-24  7:30       ` Neil Jerram
2005-03-30 18:46         ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).