Messages in this thread | | | Date | Fri, 18 Dec 1998 21:59:21 +0800 (SGT) | From | Foo Chun Choong <> | Subject | Re: "Aiee: scheduling in interrupt 00111dd2" problem |
| |
How do I protect this 'race' from happening? I'm still not clear when to use: (1) save_flags(flags); cli(); ....critical code...... restore_flags(flags); and when to use (2) start_bh_atomic(); .....critical code....... end_bh_atomic();
Question: Can I use (2) when inside an interrupt handler? BTW, to Linux what constitutes an interrupt handler? e.g. is do_dev_queue_xmit() an interrupt handler?
thanks, CCFoo
On Fri, 18 Dec 1998, Richard B. Johnson wrote:
> On Fri, 18 Dec 1998, Foo Chun Choong wrote: > > > Am I right to say that the locking structures are mainly used to prevent > > race conditions. Why does the kernel hang when some of these are broken? > > > > Observe a typical linked-list operation when the list in increasing in > size (length) .... > > link = memory_from_somewhere(); > link->next = NULL; > > Now, look while it is decreasing in size... > > while(link != NULL) { > save_next = link->next; > memory_from_somewhere_free(link); /* (A) */ > link = save_next; /* (B) */ > } > > If another "thread" were to access ``link'' between A and B, it > would be accessing invalid memory. If the first procedure was > executing and didn't finish, before the next procedure was executed, > all bets are off. This is a typical problem with multitasking, not > just SMP. Some operations must complete before others are allowed. > > This if often called a "race" condition when, in fact it's no race > at all, it's a "crash" condition, pure and simple. > > > Cheers, > Dick Johnson > ***** FILE SYSTEM WAS MODIFIED ***** > Penguin : Linux version 2.1.131 on an i686 machine (400.59 BogoMips). > Warning : It's hard to remain at the trailing edge of technology. > >
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |