caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Roewen <jonathan.roewen@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] caml_callback_depth : byterun + vmthreads
Date: Sun, 18 Dec 2005 17:20:52 +1300	[thread overview]
Message-ID: <ad8cfe7e0512172020r4c32186cu8a03518dbe013321@mail.gmail.com> (raw)
In-Reply-To: <ad8cfe7e0512171911n648c17a5nb4ac79ff75bf2498@mail.gmail.com>

> So, now gives the problem of tracking which callback calls another
> callback, that calls the scheduler, and doesn't end up doing anything
> ;-)

Well, I've tracked it down to byterun/signals.c I think:

/* Execute a signal handler immediately */

void caml_execute_signal(int signal_number, int in_signal_handler)
{
  value res;
  res = caml_callback_exn(
           Field(caml_signal_handlers, signal_number),
           Val_int(signal_number));
  /* do I need to add this? I think so... */
  caml_pending_signals[signal_number] = 0;
  if(signal_number < 16) {
      if(signal_number > 7)
        out8(0xa0,0x20);
      out8(0x20,0x20);
    }
  if (Is_exception_result(res)) caml_raise(Extract_exception(res));
}

So, am I right that what is happening is that: caml_interprete
processes signals, calls a callback (callback_depth now == 2), that
caml code tries to schedule another thread, and can't.

Now field is one of these two functions:

[vmthreads/thread.ml]
(* Preemption *)

let preempt _ =
  if !critical_section then () else thread_request_reschedule()

[kernel/interrupts.ml]
let irq_handler irq =
  if waiting.(irq) = [] then (
    recv.(irq) <- true
  ) else (
    List.iter (fun t -> Thread.wakeup t) waiting.(irq);
  );
  waiting.(irq) <- [];;

thread_request_reschedule doesn't do any callbacks, and neither does
Thread.wakeup's C implementation part.

Now I'm more confused than ever: this shouldn't be possible....

Well, this is all valid results from `grep "callback" -R .':

./byterun/finalise.c:#include "callback.h"
./byterun/finalise.c:      caml_callback (f.fun, f.val);

./byterun/printexc.c:#include "callback.h"
./byterun/printexc.c:  if (at_exit != NULL)
caml_callback_exn(*at_exit, Val_unit);

./byterun/signals.c:#include "callback.h"
./byterun/signals.c:  res = caml_callback_exn(

Any tips on tracking down this monster of a problem?

Jonathan


      reply	other threads:[~2005-12-18  4:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-18  2:48 Jonathan Roewen
2005-12-18  3:11 ` Jonathan Roewen
2005-12-18  4:20   ` Jonathan Roewen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad8cfe7e0512172020r4c32186cu8a03518dbe013321@mail.gmail.com \
    --to=jonathan.roewen@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).