[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open a file in spin_lock_irq()



Selon Ed Co <edityacomm_knb@xxxxxxxxx>:

> If I understand properly, you are using the spinlock
> to protect your list.

Yes, I do

> But why do you want to protect
> the writing to file too using the spinlock?

In fact I write in a file when my list become empty. By design, I'm writin the
file in the spinlock. My code is like:
<inside a spinlock>
  ...
  update_list();
  if list_empty
      write_file();
  ...
<outside the spinlock>

I guess that it means my design is not good and I need to move the writing to
file somwhere else outside the spinlock... for exemple:

<inside a spinlock>
  ...
  update_list();
  if list_empty
      retval = NEED_WRITING;
  ...
<outside the spinlock>

And now, outside the spinlock I can test the retrun value:
  ...
  if NEED_WRITING
     write_file();
  ...


Guillaume

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/