Re: spinlock_irq needed

Travis Geiselbrecht <[email protected]> Tue, 13 Nov 2007 13:45:00 -0800
Newsgroups gmane.os.openbeos.kernel.devel
Message-ID <[email protected]>
On Nov 13, 2007, at 11:48 AM, Axel Dörfler wrote:
> "Salvatore Benedetto" <[email protected]> wrote:
>> I followed the BeBook at this link
>> http://www.sffjunkie.co.uk/beos/BeBook/DeviceDrivers_Functions.html
>> and I'm using the following code
>>    spinlock lock = 0;
>>    cpu_status former = disable_interrupts();
>>    acquire_spinlock(&lock);
>
> Are you actually creating a spinlock on the stack? Because that
> wouldn't make any sense.

On a similar note, I solved this in newos in a different way by  
removing the need to store the state after disable_interrupts() and  
before restore_interrupts() by just sticking an irq disable level in  
the thread structure. Every time you disable it increments it, every  
time you restore it decrements it. When its > 0, interrupts are  
disabled. Works pretty well actually, except for the couple of cases  
where you have to manually mess with the count to make it look right.  
It's just folding the fact that all this state ends up on the kernel  
stack into a single variable.

Travis
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/