Is the Prolog runtime re-entrantable in Prolog --> C --> Prolog procedure?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is the Prolog runtime re-entrantable in Prolog --> C --> Prolog procedure?

Shuai Wang
Hello prolog users,


I just asked a question in this email list about 
"why failed in process of Prolog call C call Prolog"

Now after several test, I have a more general question which confused 
me...

I myself have some experience about using C call Prolog and 
using Prolog to call C in GNU-Prolog, however, I have several 
strange problems in recent test of procedure below:

     C -- call -- > Prolog -- call --> C -- call --> Prolog 
     -- return --> C -- return --> Prolog (fail..)

So basically, is the Prolog runtime reentrantable in Prolog --> C --> Prolog
procedure..?


I attached my test code in the email, in this code, the weird thing is that return value of TMP  in  Prolog function foo  can not be binded.

BTW:  Is it something related to the arguments of 
Pl_Query_Begin; Pl_Query_End ?


Best,
Shuai


_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog

simple.cil.c (4K) Download Attachment
babel.c (1K) Download Attachment
babel.pl (1K) Download Attachment
Makefile (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Is the Prolog runtime re-entrantable in Prolog --> C --> Prolog procedure?

Daniel Diaz-3
Hi,

sorry for the late reply. There are possibly reentrancy issues with gprolog. However, your example is too complex as is to be used for debugging purpose. Could you minimize it as most as possible so I could try to understand what happens ?

Thank you

Daniel


Le 24 juil. 2014 à 20:24, Shuai Wang <[hidden email]> a écrit :

Hello prolog users,


I just asked a question in this email list about 
"why failed in process of Prolog call C call Prolog"

Now after several test, I have a more general question which confused 
me...

I myself have some experience about using C call Prolog and 
using Prolog to call C in GNU-Prolog, however, I have several 
strange problems in recent test of procedure below:

     C -- call -- > Prolog -- call --> C -- call --> Prolog 
     -- return --> C -- return --> Prolog (fail..)

So basically, is the Prolog runtime reentrantable in Prolog --> C --> Prolog
procedure..?


I attached my test code in the email, in this code, the weird thing is that return value of TMP  in  Prolog function foo  can not be binded.

BTW:  Is it something related to the arguments of 
Pl_Query_Begin; Pl_Query_End ?


Best,
Shuai


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé. <simple.cil.c><babel.c><babel.pl><Makefile>_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.
_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

Re: Is the Prolog runtime re-entrantable in Prolog --> C --> Prolog procedure?

Shuai Wang
Hello Dr. Diaz,

Yes, I simplified the case I attached before. 

Generally there are two functions in prolog, foo and foo1. 

In the main function of Simple.c, prolog's function foo is called (through foo's wrapper). 

Then in prolog foo, foo1's C wrapper is called. This wrapper would call foo1's 
implementation inside prolog .

The problem is that there is a reentrancy from C to Prolog here 
" foo C wrapper --> foo " and " foo1 C wrapper --> foo1".

and the problem is that 
when execution flow return back to foo, the TMP variable can not be binded (line 6 in babel.pl).

I have tested other cases, and similar issues happened.

Am I clear enough?

Thank you a lot!

Best,
Shuai



On Wed, Aug 13, 2014 at 3:24 AM, Daniel Diaz <[hidden email]> wrote:
Hi,

sorry for the late reply. There are possibly reentrancy issues with gprolog. However, your example is too complex as is to be used for debugging purpose. Could you minimize it as most as possible so I could try to understand what happens ?

Thank you

Daniel


Le 24 juil. 2014 à 20:24, Shuai Wang <[hidden email]> a écrit :

Hello prolog users,


I just asked a question in this email list about 
"why failed in process of Prolog call C call Prolog"

Now after several test, I have a more general question which confused 
me...

I myself have some experience about using C call Prolog and 
using Prolog to call C in GNU-Prolog, however, I have several 
strange problems in recent test of procedure below:

     C -- call -- > Prolog -- call --> C -- call --> Prolog 
     -- return --> C -- return --> Prolog (fail..)

So basically, is the Prolog runtime reentrantable in Prolog --> C --> Prolog
procedure..?


I attached my test code in the email, in this code, the weird thing is that return value of TMP  in  Prolog function foo  can not be binded.

BTW:  Is it something related to the arguments of 
Pl_Query_Begin; Pl_Query_End ?


Best,
Shuai


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé. <simple.cil.c><babel.c><babel.pl><Makefile>_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog


--
Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé.


_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog

babel.pl (336 bytes) Download Attachment
babel.c (364 bytes) Download Attachment
Makefile (86 bytes) Download Attachment
simple.c (1K) Download Attachment