From: cowan@mercury.ccil.org (John Cowan)
Subject: [TUHS] Etymology of the open file table?
Date: Tue, 22 Mar 2016 00:00:04 -0400 [thread overview]
Message-ID: <20160322040004.GB25603@mercury.ccil.org> (raw)
In-Reply-To: <CAEoi9W5J0Jnrcq1Yug65cKZaJ2wdhBM1-BjkGoWPFjoLqo-jsA@mail.gmail.com>
Dan Cross scripsit:
> Those file structures are collected into a single, global table. The
> question is why this latter table? One could rather imagine an
> implementation where open() allocates (e.g., via malloc()) a new 'struct
> file' that contains as a structure field an 'int refcnt' that is
> incremented when a descriptor is dup()'d or as a side-effect of a fork(),
> and is decremented as a result of a close(); when 'refcnt' drops to zero,
> the structure could be freed with e.g. 'mfree'. What is the benefit of
> 'struct file file[];'?
Sure you could, but it would be more complex, slower, and less robust.
"When in doubt, use brute force." --ken
--
John Cowan http://www.ccil.org/~cowan cowan at ccil.org
He made the Legislature meet at one-horse tank-towns out in the alfalfa
belt, so that hardly nobody could get there and most of the leaders
would stay home and let him go to work and do things as he pleased.
--H.L. Mencken's translation of the Declaration of Independence
next prev parent reply other threads:[~2016-03-22 4:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 2:07 Dan Cross
2016-03-22 2:23 ` Marc Rochkind
2016-03-22 2:28 ` Larry McVoy
2016-03-22 2:56 ` Warren Toomey
2016-03-22 3:02 ` Dan Cross
2016-03-22 3:02 ` Dan Cross
2016-03-22 4:00 ` John Cowan [this message]
2016-03-22 4:11 ` Warner Losh
2016-03-23 19:48 ` Dan Cross
2016-03-23 20:17 ` John Cowan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160322040004.GB25603@mercury.ccil.org \
--to=cowan@mercury.ccil.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).