Page 1 of 1

How to safely overwrite memory in use by variables?

Posted: Sat Jun 22, 2013 3:00 pm
by CocaCola
Hello.
I'm trying to code a Memtest-like OS, that needs to test available memory for errors.

A very crude memory test could consist of overwriting a chunk of memory with a constant value, then go back and check if the value changed anywhere.

My question is: what can I do about the kernel's variables, which appear scattered in the memory?
Are there some segment relocation tricks that could help with this?
Thanks.

Re: How to safely overwrite memory in use by variables?

Posted: Sat Jun 22, 2013 3:43 pm
by bluemoon
1. test the region excluded by memtest
2. copy memtest to other region and jump there
3. test the region previously skipped.

This is easier to do with paging.

However, write-read test is only able to detect certain defeats, while sometime unstable ram (due to over-clock or mix of different brand of ram) may still pass the test.

Re: How to safely overwrite memory in use by variables?

Posted: Sat Jun 22, 2013 3:53 pm
by FallenAvatar
I'm not sure how Memtest does it, but it is open source, so you can always look there: http://www.memtest.org/ That is my goto for memory testing *shrug*

- Monk