Re: Most elegant way to read to allocatable array?



Jan Vorbrüggen wrote:
That would be a lock that's needed whether the I/O used unit numbers
or handles. The lock on the I/O unit table is unlocked as soon as
you've looked up the corresponding handle. Since it's only a
table lookup it's fast and no thread spends much time in that
critical section.

In addition, you could have code in the library, or even the
generated code, that cached the translation.

That would not be a good idea. At least in unix-like environments,
file handles tend to be pointers. The type is usually something like
(FILE *) in C. Caching copies of pointers is unsafe. Suppose the
file is closed through one copy: you'd have a dangling pointer to
the (now non-existent) FILE struct.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


.



Relevant Pages

  • Re: [PATCH 08 of 11] anon-vma-rwsem
    ... have the padding due to the alignment of the 64-bit pointers in the ... On 32-bit, the alignment of list-head is obviously just 32 bits, so right ... now the structure is "perfectly packed" and doesn't have any empty space. ... spinlock_t lock; ...
    (Linux-Kernel)
  • Re: file locking.
    ... On Thu, 16 Aug 2007, John Baldwin wrote: ... I just introduced an extra flag so I could remove the race from dropping the lock inbetween operations and get an accurate count of how big the array needs to be. ... What's more troubling is the continued erosion of support for libkvm as it ... Well shaving off two pointers gets us into cacheline size for struct file which has some perf improvement. ...
    (freebsd-arch)
  • Re: Surprise
    ... Compilers were *obviously* not portable, ... Fortran ... stance on pointers more seriously. ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: Smart Pointers and Microsoft Foundation Classes
    ... LockProxy operator++{ ... lock l; ... problems that come with raw pointers, such as the need to delete them at ... Ownership is always important. ...
    (microsoft.public.vc.mfc)
  • Re: Accessing process information from inside a LKM?
    ... > not aware of a kernel interface to lock the list and iterate across it. ... of the proc struct changes frequently. ... Does one navigate the process list using the five child/sibling pointers or by ... Jimmie Mayfield http://www.sackheads.org/mayfield email: mayfield+usenet@sackheads.org My mail provider does not welcome UCE -- http://www.sackheads.org/uce ...
    (comp.sys.hp.hpux)