How to safely overwrite memory in use by variables?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
CocaCola
Member
Member
Posts: 36
Joined: Fri Sep 07, 2012 9:11 am

How to safely overwrite memory in use by variables?

Post 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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post 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.
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

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

Post 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
Post Reply