MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to interrupt a running evaluation in MathLink

  • To: mathgroup at
  • Subject: [mg16917] Re: How to interrupt a running evaluation in MathLink
  • From: tobiasoed at
  • Date: Thu, 8 Apr 1999 02:32:30 -0400
  • Organization: Deja News - The Leader in Internet Discussion
  • References: <7e9olb$>
  • Sender: owner-wri-mathgroup at

Hi,	Interrupts over mathlink are poorly documented. There are discussions
going on about this in other threads. There is a mathlink function you can
call: MLPutMessage(link,integer) as far as I know, this is undocumented.
Symbolic constants for the second argument are defined in mathlink.h and
their names are MLInterruptMessage, MLAbortMessage etc... One of the problems
I have with this is that the kernel does not answer in the same manner when
waiting for input or evaluating. I do not know how to avoid a race conditions
that may occure. Also depending on how you start the kernel the MLPutMessage
works or fails-see another of my posts to the newsgroup (it's recent, so it
should still be there).

Hope this helps Tobias

In article <7e9olb$3ku at>,
  rmille1 at (RMille1) wrote:
> I'm using Mathlink in my C program to start a Mathlink kernel and send this
> expression to be evaluated:
> N[ReplaceAll["Some expression",x->"some variable"]]
> Everything is working otay. However, occasionally an expression I send causes
> the kernel to evaluate for longer than I would like it to. So what I want to
> is interrupt the evaluation and abort just as it would from a command line
> Ctr-C and abort, but through MathLink. Here's the snippet of code that will
> call it:
> pkt = MLFlush(Link);
> interval = 0;
> while((!MLReady(Link))&&(interval<=10))
> {
> 	interval++;
> 	Sleep(500);
> }
> if(interval > 10)
> {
> dump = fopen("dump.txt","a");//test
> fprintf(dump,"\n/////////////////////Restarting
> Kernel///////////////////\n\n");//test
> fclose(dump);  //test
> ***** Interrupt and Abort here. ************
> 	return 0;
> }
> I know there's a way to do this with MLAbort from the kernel, but not the
> way. Also I didn't use Loopback or mprep,
> One other thing. I found the MathLink Tutorial by Todd Gayley to be the best
> resource for learning how to use MathLink to start and run a Math kernel from
> C. However, it seems a little dated. I'm using
> char *argv[5] = {"-linkname",
>                  "c:\\progra~1\\wolfra~1\\mathem~1\\3.0\\math -mathlink",
>                       "-linkmode",
>                       "launch",
>                       NULL};
> with MLOpen(), and that doesn't jive with the documentation in Mathematica 3.0
> Is there a more up to date version available?

-----------== Posted via Deja News, The Discussion Network ==----------       Search, Read, Discuss, or Start Your Own    

  • Prev by Date: Re: question about entering vectors by the keyboard
  • Next by Date: RE: Plot
  • Previous by thread: Re: How to interrupt a running evaluation in MathLink
  • Next by thread: Re: How to interrupt a running evaluation in MathLink