[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] swap problem



Mat Kovach <mkovach@xxxxxxxxxxxxxxxxx> writes:

> : > I'm not sure what you mean by swap file here?  Linux (and Cobalt) use swap
> : > partitions for virtual memory, paging memory in and out of swap when needed.

> : You can use swap files with Linux.

> You can use swap files, but they act just like a swap partition, only the file
> descriptor is different.  But once setup by the kernel, the same code works
> on both.  This is because /dev/hda2 looks like /swap to the kernel :)

I suppose you've never really read the kernel source for the VM?

Internally swap files and swap partitions are in many ways handled
equally, but at some (low level) point - they must be treated
differently. There's no concept of "file descriptors" to be put in use
here.

There's a subtle difference between writing/reading to a partition and
a file. Then you read/write to a file, it (the smap()) must go through
the filesystem (you can have swapfiles on a vfat filesystem, fx). When
you're dealing with a partition, you can "just" write as you like.

Imagine networked swapfiles... not quite the same thing as a direct
write...

In the code you see a lot of branches, being "is swap file? or
partition?" ... there's a reason for those!
 


-- 
Jens Kristian Søgaard,
jk@xxxxxxxxxxxx -- http://www.jksoegaard.dk/
Søger du noget? -- http://www.google.com/