[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: open a file in spin_lock_irq()
hi,
Not know much about yr question but share something
with you ,
what i had done was used a counter which is of type
atomic_t ,and try to simulate semaphore like situation
,where critical region check for 0 of the counter
this way interrupts remain enable as u already wrote
that,u had tried spin_lock,so how exactly to do this
i think you better know,anyway your intention is to
protect a shared list which can be done.
if this is not what you expect then plz ignore this
thanks
Prasanna
--- Guillaume Thouvenin
<guillaume.thouvenin@xxxxxxxxxx> wrote:
> Selon Guillaume Thouvenin
> <guillaume.thouvenin@xxxxxxxxxx>:
>
> > I wrote a piece of kernel code that deals with
> new structure. Those
> > stucture
> > are manipulated by a driver. So, I implemented a
> classical ioctl() with a
> > switch
> > to select appropriate action to perform. One of
> this action is to remove a
> > data
> > from a list:
>
> Oops, some parts of the mail are missing so I
> resume:
>
> I implemented the ioctl as follow:
>
> int my_ioctl(...) {
> ...
> switch(cmd) {
> case REMOVE_AN_ITEM:
> spin_lock_irq(&my_lock);
> update_my_structure();
> spin_unlock_irq(&my_lock);
> break;
> ....
> }
> }
>
> Function update_my_structure() remove an item from a
> list of items and if the
> list is empty, it dumps information about this list
> in a file. So, in this
> function I call filp_open() if list is empty. The
> problem is that you can not
> call filp_open() if you are in a spinlock because
> irq must be enable. So my
> question is how can you open a file if you are in a
> spin_lock_irq()? Can I use
> spin_lock() instead of spin_lock_irq() when doing
> some ioctl?
>
> I tried (peudo-code):
>
> int update_my_structure()
> {
> ...
> remove_item();
> if (list is empty()) {
> local_irq_enable();
> f = filp_open();
> f->write(info);
> filp_close(f);
> local_irq_disable();
> }
> ...
>
>
> But it doesn't work. It seems that it produces a
> lock and kernel freezes.
>
> Thanks for your help
> Guillaume
>
> --
> Kernelnewbies: Help each other learn about the Linux
> kernel.
> Archive:
> http://mail.nl.linux.org/kernelnewbies/
> FAQ: http://kernelnewbies.org/faq/
>
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/