Mailing List Archive


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

Re: [tlug] Questions about specifications for some cutting edge videorecording via laptop



Josh Glover wrote:
> Yes, writes are buffered and written in a file-independent manner. The
> write(3) syscall simply places the data to be written in the block
> buffer, which the Linux kernel then writes to disk in an intelligent
> fashion. So it should not matter how many files you are writing to,
> the disk will still be used efficiently.

Not exactly. write(2, sorry) syscall places the data to the block
device, only if the opened file is a block device.
On most Unix-like systems, you can access the same devices, but in
a raw mode. Example: dd [...] of=my-raw-disk will not use at all the
block device.

The write(2) syscall sends a command to the underlying device (mainly
block or raw).

I would like to add that write(), even on a block device, could be
highly inefficient. Just try to "write" one char at once 1,000,000
times. Try again with a library call (3) like putc() - that one
will add one more layer of "caching". This is of course
more visible with some kind of seeks in middle of the write...
You just have to manage yourself the balance between security and
speed, depending also on the way you need to write.

You can do the same with memory only: Allocate (your memory * 2) with
a malloc(3!). Then fill it with a double loop:
1  for (b=0; b<nb_blocks; b++)
2	  for (c=0; c<b_size; c++)
3		  *(b*b_size+c) = 0;

Try this, Then invert lines 1 and 2, and compare the execution time.
This is a problem with some developpers, as they don't understand the
underlying layers...
You can try this with b_size=4k for instance, and nb_blocks being
your memory * 2 / b_size (assuming you have enough swap). In fact
physical memory + 1 block will give the same result, probably.


br.

--
GPG Key: 653514E5 (http://www.raoult.com/gpg)
--
Yoda: "No! Try Not! Do! Or Do not! There IS no try. Only Do."
Yoda showed Luke what could be done.
Luke: "I don't believe it..."
Yoda: "That, is why you fail..."

Attachment: signature.asc
Description: OpenPGP digital signature


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links