If the two blocks overlap, and the address of dst is greater than the address of src, then parts of the source will be overwritten before it can be copied.
The original v6 doesn’t have any of the mem* functions, but its bcopy implementation has the same issue. Presumably the convention that bcopy permits overlap had not been established at that time.
At least two bugs: the test should compare vdst to vsrc, not * vdst to * vsrc, and in the first branch you're copying vsrc[n] which is out of range (and skipping vsrc[0]).
The first bug I'm confused? Surely we want to use the * because we're comparing the position in memory, not what's in the memory? Or does the * mean "compare what is in that memory slot"?
I see an additional bug in there compared to the original, you're copying the memory below vsrc into the memory below vdst in the first branch. you need to add to dst and src not vdst/vsrc.
> The memory areas may overlap: copying takes place as though the bytes in src are first copied into a temporary array that does not overlap src or dest, and the bytes are then copied from the temporary array to dest.
Here is a standard implementation I found from some code at work.
/* memmove.c -- copy memory.
Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate.
In the public domain.
By David MacKenzie <djm@gnu.ai.mit.edu>. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
void *
memmove (dest, source, length)
char *dest;
const char *source;
unsigned length;
{
char *d0 = dest;
if (source < dest)
/* Moving from low mem to hi mem; start at end. */
for (source += length, dest += length; length; --length)
*--dest = *--source;
else if (source != dest)
{
/* Moving from hi mem to low mem; start at beginning. */
for (; length; --length)
*dest++ = *source++;
}
return (void *) d0;
}
"Nicolas Bourbaki is the collective pseudonym under which a group of (mainly French) 20th-century mathematicians wrote a series of books presenting an exposition of modern advanced mathematics, beginning in 1935. With the goal of founding all of mathematics on set theory, the group strove for rigour and generality. Their work led to the discovery of several concepts and terminologies still discussed."
I was under the impression that Minix was created and used for this kind of thing. Is there something about Minix that makes it unsuitable today's classrooms?
Microkernels have been the wave of the future for longer than some of the most popular OSes have been around, namely Windows NT (not just Windows 7, but the whole NT design), Mac OS X (NeXTStep too, for that matter), and Linux (but, admittedly, not Unix).
If I may prognosticate, stripped-down monolithic OSes running on hypervisors are the wave of the future. Look at VM/CMS for an extreme example: CMS is about as complex as MS-DOS, being a single-user single-tasking OS with no memory protection or security model. VM is the hypervisor. Together, they date to about 1968, or a little before if you include research systems.
There are a lot of parallels between VM/CMS and a microkernel with a service built specifically to host an application. They are very different beasts at their core (a microkernel is built to connect services and a hypervisor to segregate them), but they solve similar problems in sometimes similar ways.
A Service VM is one where an application runs directly on the 'bare metal' provided by the VM (that is, the whole point of a VM is to multiplex the hardware; it provides few or no abstractions as such). There's no guest OS as you'd think of one.
In an exokernel, the guest OS is reduced to a library, like libc, which is (ideally) optimized for the specific application: Emacs has its own, Apache has its own, and so on. It's a half-step removed from the Service VM idea in that the applications themselves would still get to use the OS abstractions, unaware that the OS is basically gone.
A suitably motivated individual might reach out to the various accredited institutions, try and track down one of the Cmpt. Sci Profs who teaches the "Intro to Operating Systems" courses, and find out
A) Which Textbook they Use.
B) Which training OS system they use.
C) Which language they implement their OS in. (ANSI C is likely to be popular)
Or, they could be lazy, and hope that this HN thread turns out to be a representative sample of the Textbooks/Operating Systems in use.
I encourage you to try out the 6.828 course material, especially the labs. It's one of the best OS courses. I had taken UCLA's CS 235 which is based on similar content [1]. Learned a lot from that.
> Although the Unix v6 source may seem like an ideal introduction to operating systems engineering because of its simplicity, students doubted the relevance of an obsolete OS written in a now defunct dialect of C. In addition, students struggled to learn the details of two different architectures, the PDP-11 and x86, at the same time.
Those students were MIT students. I'd expect MIT students to not have had a problem with either of these, so I'm a bit puzzled.
Compared to the OS course I've taken in Sweden this seems to cover more, but I can't find how many credits you get from it. It is scheduled from September to end of december, but is it full time during this period or do they take other courses at the same time?
Comer has a new edition of "Operating System Design: The Xinu Approach" that focuses on a Linksys/Cisco router. I've not read the text officially yet, but the drafts were very interesting. Purdue CS grad students use Xinu for the OS course projects (http://www.cs.purdue.edu/homes/cs503/).