[m-rev.] for review: support STM in low level grades

Ben Mellor bmellor at csse.unimelb.edu.au
Mon May 4 09:48:37 AEST 2009


> Index: library/stm_builtin.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/library/stm_builtin.m,v
> retrieving revision 1.14
> diff -u -r1.14 stm_builtin.m
> --- library/stm_builtin.m	26 Feb 2009 23:43:08 -0000	1.14
> +++ library/stm_builtin.m	3 May 2009 12:23:54 -0000
> @@ -368,13 +368,100 @@
>  
>  %-----------------------------------------------------------------------------%
>  
> +
> +% In high level C grades, stm_block calls a C procedure in the runtime that
> +% blocks the POSIX thread until signalled, as there is one POSIX thread for
> +% every Mercury thread.
> +% In the low level C grades, this approach cannot be taken, as when the
> context +% blocks the engine running in the POSIX thread needs to be able to
> look for +% other work (there might only be a single engine/POSIX thread).
> +
>  :- pragma foreign_proc("C",
>      stm_block(STM::ui),
>      [will_not_call_mercury, thread_safe],
>  "
> +#if defined(MR_HIGHLEVEL_CODE)
>      MR_STM_block_thread(STM);
> +#else
> +
> +    MR_STM_wait(STM, STM);
> +
> +#if defined(MR_STM_DEBUG)
> +        fprintf(stderr, ""STM BLOCKING: log <0x%.8lx>\n"", STM);
> +#endif

I've corrected \n"" to \\n"".

> +
> +    MR_save_context(MR_ENGINE(MR_eng_this_context));
> +
> +    MR_ENGINE(MR_eng_this_context)->MR_ctxt_resume =
> +        MR_ENTRY(mercury__stm_builtin__block_thread_resume);
> +
> +    MR_ENGINE(MR_eng_this_context) = NULL;
> +    MR_UNLOCK(&MR_STM_lock, ""MR_STM_block_thread"");
> +    MR_runnext();
> +
> +#endif
>  ").
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list