SIDEBAR :: Testing the memcpy() C program

Now that we better understand the what and why of a VM system, let's go back to the buggy pseudocode example we considered at the beginning of this chapter: the case where we used memcpy(3) to copy some memory but specified the wrong destination address (and it would have overwritten the OS itself in our fictional physical-memory-only system).

A conceptually similar C program, but which runs on Linux—a full-fledged virtual-memory-enabled OS—is shown and tried out here. Let's see how the buggy program works on Linux:

$ cat mem_app1buggy.c/* * mem_app1buggy.c * *************************************************************** * This program is part of the source code released for the book * "Linux System ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.