[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: MzScheme Special Form -> Native Numerical Code?



> By the way, the educational motivation for generating and calling native
> code from MzScheme is that then TeachScheme! can then be easily extended
> into classes for advanced students on low level machine architecture.
> Students could learn how a real processor works by poking at it through
> MzScheme interface functions. Need to add a new language level then --
> "crash and burn horribly". :-) But as I've heard it said, "If you can't
> crash it, you're not the one doing the driving..."


I know this sounds like a contradiction, but I wonder whether there would be
a 
"safe" way to "crash and burn horribly." Recently, Matthew Flatt pointed
me to a paper overviewing various garbage collectors. The idea that comes to
mind is that you could use the write barier of the garbage collector to make
sure that machine instructions from a "crash and burn routine" didn't
actually
trash other unrelated parts of the system.

The idea is that (call-native-code someSortOfByteArray memory-size) would
set aside some
memory that the native-code could write to. The native-code would be free to
do whatever
it wanted in that memory, but if it tried to write to another part of
memory,
MzScheme would stop the native-code execution and raise an exception.