RE: Semaphore and Spinlock

2015-04-27 Thread Jeff Haran
> -Original Message- > From: kernelnewbies-boun...@kernelnewbies.org [mailto:kernelnewbies- > boun...@kernelnewbies.org] On Behalf Of Ruben > Sent: Monday, April 27, 2015 12:10 PM > To: kernelnewbies@kernelnewbies.org > Subject: Re: Semaphore and Spinlock > >

Re: Semaphore and Spinlock

2015-04-27 Thread Ruben
On 04/27/2015 12:31 PM, Jeff Haran wrote: >> -Original Message- >> From: kernelnewbies-bounces+jharan=bytemobile@kernelnewbies.org >> [mailto:kernelnewbies- >> bounces+jharan=bytemobile@kernelnewbies.org] On Behalf Of >> Abhishek Bist >> Sent: Monday, April 27, 2015 6:19 AM >> To:

RE: Semaphore and Spinlock

2015-04-27 Thread Jeff Haran
> -Original Message- > From: kernelnewbies-bounces+jharan=bytemobile@kernelnewbies.org > [mailto:kernelnewbies- > bounces+jharan=bytemobile@kernelnewbies.org] On Behalf Of > Abhishek Bist > Sent: Monday, April 27, 2015 6:19 AM > To: kernelnewbies@kernelnewbies.org > Subject: Semapho

Re: Semaphore and Spinlock

2015-04-27 Thread Ruben Safir
On 04/27/2015 09:18 AM, Abhishek Bist wrote: > [ Semaphores are a bit like spinlocks, except the holder of a semaphore is a > process, not a CPU. ] > This is a very first line that is bein written on the description of > semaphore on kernel newbies.So what are the different parameter > that coul

Re: Semaphore

2012-02-28 Thread Rajath N R
Hi, Once process terminated for what ever reason, kernel should release all the resources held by that process including lock. do_exit()-->exit_sem(). thanks, Rajath On Tue, Feb 28, 2012 at 1:53 PM, Rajath N R wrote: > Hi, > I think santosh is talking about user land IPC (semget). > thre

Re: Semaphore

2012-02-28 Thread Rajath N R
Hi, I think santosh is talking about user land IPC (semget). thread/process which has acquired a sema lock/sem down using semop(2) syscall. Thanks, Rajath On Fri, Feb 24, 2012 at 3:54 PM, Kristof Provost wrote: > On 2012-02-24 12:15:03 (+0200), Kosta Zertsekel > wrote: > > I think of use

Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 12:15:03 (+0200), Kosta Zertsekel wrote: > 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

Re: Semaphore

2012-02-24 Thread Kosta Zertsekel
>> >> 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 e

Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 11:25:00 (+0200), Kosta Zertsekel wrote: > On Fri, Feb 24, 2012 at 11:04 AM, Kristof Provost wrote: > > On 2012-02-24 09:07:40 (+0200), Kosta Zertsekel wrote: > >> >> > Imagine a driver which only one app can use at a time (perhaps a > >> >> > serial > >> >> > port). The kernel wi

Re: Semaphore

2012-02-24 Thread Kosta Zertsekel
On Fri, Feb 24, 2012 at 11:04 AM, Kristof Provost wrote: > On 2012-02-24 09:07:40 (+0200), Kosta Zertsekel wrote: >> >> > Imagine a driver which only one app can use at a time (perhaps a serial >> >> > port). The kernel will take a lock when the user space app open()s the >> >> > device node and

Re: Semaphore

2012-02-24 Thread Kristof Provost
On 2012-02-24 09:07:40 (+0200), Kosta Zertsekel wrote: > >> > Imagine a driver which only one app can use at a time (perhaps a serial > >> > port). The kernel will take a lock when the user space app open()s the > >> > device node and release it when it close()s. > >> > If the app segfaults in bet

Re: Semaphore

2012-02-23 Thread Kosta Zertsekel
>> > Imagine a driver which only one app can use at a time (perhaps a serial >> > port). The kernel will take a lock when the user space app open()s the >> > device node and release it when it close()s. >> > If the app segfaults in between the open() and close() the lock will >> > still get release

Re: Semaphore

2012-02-22 Thread SaNtosh kuLkarni
Hi Guys, Thanks for the replies and your interest and your time :) :) cause i did not know if it was a valid doubt , ya my doubt was on how to handle situations like this...i would also like to add few more doubts/append/ to my previous question and make the question more clear.. You have thread/

Re: Semaphore

2012-02-22 Thread Sri Ram Vemulpali
The original question was "how can one can handle safe release of semaphore when a process dies after acquiring semaphore?". This is causing the semaphore to be in acquired state, resulting other processes to wait on it. Regardless of file handling in the kernel, how kernel cleans up the resources

Re: Semaphore

2012-02-22 Thread Kristof Provost
On 2012-02-22 11:53:12 (+), Anuz Pratap Singh Tomar wrote: > On Wed, Feb 22, 2012 at 9:48 AM, Kristof Provost wrote: > > > On 2012-02-22 11:01:52 (+0200), Konstantin Zertsekel > > wrote: > > > On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands > > wrote: > > > > I'm assuming that the semaphore

Re: Semaphore

2012-02-22 Thread Anuz Pratap Singh Tomar
On Wed, Feb 22, 2012 at 9:48 AM, Kristof Provost wrote: > On 2012-02-22 11:01:52 (+0200), Konstantin Zertsekel > wrote: > > On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands > wrote: > > > I'm assuming that the semaphore is one which is held across multiple > > > calls into the kernel, otherwise yo

Re: Semaphore

2012-02-22 Thread Kristof Provost
On 2012-02-22 11:01:52 (+0200), Konstantin Zertsekel wrote: > On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands wrote: > > I'm assuming that the semaphore is one which is held across multiple > > calls into the kernel, otherwise you don't have an issue in the first > > place, unless there is a bug o

Re: Semaphore

2012-02-22 Thread Konstantin Zertsekel
On Tue, Feb 21, 2012 at 6:14 PM, Dave Hylands wrote: > Hi Santosh, > > On Tue, Feb 21, 2012 at 5:47 AM, SaNtosh kuLkarni > wrote: >> A certain  kernel process has acquired a semaphore lock and meanwhile during >> this period the process gets killed abruptly (and it has not released the >> sem loc

Re: Semaphore

2012-02-21 Thread Dave Hylands
Hi Santosh, On Tue, Feb 21, 2012 at 5:47 AM, SaNtosh kuLkarni wrote: > A certain  kernel process has acquired a semaphore lock and meanwhile during > this period the process gets killed abruptly (and it has not released the > sem lock..//.sem down).and the other processes cannot acquire the l

Re: Semaphore

2012-02-21 Thread Konstantin Zertsekel
On Tue, Feb 21, 2012 at 3:47 PM, SaNtosh kuLkarni wrote: > A certain kernel process has acquired a semaphore lock and meanwhile during > this period > the process gets killed abruptly (and it has not released the sem > lock..//.sem down). > and the other processes cannot acquire the lock, wh