kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: zertsekel@gmail.com (Kosta Zertsekel)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Semaphore
Date: Fri, 24 Feb 2012 12:15:03 +0200	[thread overview]
Message-ID: <CADxo8W+V7Yvy38qb8itzyVdy6LDDGr_doHBNEQPJNvGuHkqc4A@mail.gmail.com> (raw)
In-Reply-To: <20120224092852.GR10865@thebe.jupiter.sigsegv.be>

>> >> Can you please point to some code in Linux Kernel that does the job?
>> >
>> > In kernel/exit.c, look at do_exit(). It cleans up a process after it's
>> > terminated (for whatever reason).
>> > It does a lot of cleanup, but through exit_files() -> put_files_struct()
>> > -> close_files() it ends up iterating over all open file descriptors and
>> > closing them.
>> > What's done for each close depends on what the process had open. Normal
>> > files will just be closed, or a TCP socket might be closed, or if a
>> > device node was opened the corresponding drivers close() function will
>> > be called.
>>
>> I meant that I don't see any semaphore related stuff in do_exit().
>> It seems that semaphore just remains there in the system after a user
>> land task is killed...
>>
> In this (fictional, I've not looked at the serial driver code) example I'm
> assuming a semaphore owned by a driver. The user space application is using
> the driver through a device node. The semaphore is managed by the driver,
> and released when the close is called.
> The driver does not know how (or even if) the application stopped, only
> that it closed the file descriptor.
>
> What specific type of semaphore are you interested in? Who acquires it,
> what does it protect?

I think of user land program opening a socket and crashing on
segmentation fault.
In code 'socket' syscall does:
    sock_map_fd --> sock_alloc_file --> alloc_file --> ... get lost ...
Where exactly in this case lock is held - I mean the lock that gets
released when user land process dies?
Thanks,
--- KostaZ

  reply	other threads:[~2012-02-24 10:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-21 13:47 Semaphore SaNtosh kuLkarni
2012-02-21 15:12 ` Semaphore Konstantin Zertsekel
2012-02-21 16:14 ` Semaphore Dave Hylands
2012-02-22  9:01   ` Semaphore Konstantin Zertsekel
2012-02-22  9:48     ` Semaphore Kristof Provost
2012-02-22 11:53       ` Semaphore Anuz Pratap Singh Tomar
2012-02-22 12:11         ` Semaphore Kristof Provost
2012-02-22 14:31           ` Semaphore Sri Ram Vemulpali
2012-02-23  6:12             ` Semaphore SaNtosh kuLkarni
2012-02-24  7:07               ` Semaphore Kosta Zertsekel
2012-02-24  9:04                 ` Semaphore Kristof Provost
2012-02-24  9:25                   ` Semaphore Kosta Zertsekel
2012-02-24  9:28                     ` Semaphore Kristof Provost
2012-02-24 10:15                       ` Kosta Zertsekel [this message]
2012-02-24 10:24                         ` Semaphore Kristof Provost
2012-02-28  8:23                           ` Semaphore Rajath N R
2012-02-28  8:33                             ` Semaphore Rajath N R

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=CADxo8W+V7Yvy38qb8itzyVdy6LDDGr_doHBNEQPJNvGuHkqc4A@mail.gmail.com \
    --to=zertsekel@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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).