Currently, the code used to access VGA does plain memory pokes:
for (i, &byte) in HELLO.iter().enumerate() {
unsafe {
*vga_buffer.offset(i as isize * 2) = byte;
*vga_buffer.offset(i as isize * 2 + 1) = 0xb;
}
}
This surprised me — I expected to see something like ptr::write_volatile here. Are you sure this code isn't working by accident?
I'm not too familiar with the exact semantics, but my guess would be that without volatile, these memory accesses are not considered side-effects, and therefore the compiler could, for example:
prove that our code won't read them (because of an upcoming infinite loop, for example), and decide remove them
move the write around some code that might not terminate, for example:
print("doing the thing... ");
some_mutex.lock().push(42);
print("it worked!");
could get optimised to
some_mutex.lock().push(42);
print("doing the thing... it worked!");
This would suck big time if you're trying to track down a deadlock.
Is this something you've given some thought, or merely an oversight?
Currently, the code used to access VGA does plain memory pokes:
This surprised me — I expected to see something like
ptr::write_volatile
here. Are you sure this code isn't working by accident?I'm not too familiar with the exact semantics, but my guess would be that without volatile, these memory accesses are not considered side-effects, and therefore the compiler could, for example:
could get optimised to
This would suck big time if you're trying to track down a deadlock.
Is this something you've given some thought, or merely an oversight?