Partial application in C
David Chase
chase at Ozona.orc.olivetti.com
Sat Jul 9 05:26:05 AEST 1988
In article <429 at uwovax.uwo.ca> 16012_3045 at uwovax.uwo.ca (Paul Gomme) writes:
>in order to allow for "orderly" multitasking - i.e. if one process runs
>amok, it shouldn't affect the other processes, which could occur if a program
>can alter its code segment.
> Besides, I thought that self-modifying code was (a) extremely difficult
>to write, and (b) considered poor programming practice.
Let me try to put this discussion back on track (or shelve it
permanently). Note the subject: "Partial application in C".
Modifying code segments is totally unrelated; what I wanted to know
was, "what machines allow or don't allow execution within the data
segment". This is NOT self-modifying code, this is a technique for
implementing partial application. Because I am only creating code,
then executing it (perhaps) several times, it is possible for me to
(a) execute NOPS to clean out the instruction pipeline
or
(b) execute cache flush instructions
or
(c) execute a special block of some number of nops/jumps to be sure
to touch the instruction cache line where the data might be
stored (in the event that we are reusing some data addresses for
a second round of code generation).
or
(d) call the OS to modify or copy the data into the code segment
before returning from the subroutine which performs the partial
application.
The code (which is not self-modifying) is easy to write; it is
generated by a subroutine call.
Partial application is not poor programming practice. Again, what I
(still) wish to know is what machines/operating systems allow me to
use this technique for implementing partial application, and which
ones require one of the magic handshakes (a,b,c,d) listed above, and
which machines make it totally impossible.
David Chase
Olivetti Research Center, Menlo Park
More information about the Comp.lang.c
mailing list