[Info-vax] Volatile, was: Re: yet another sys$qiow question

Johnny Billquist bqt at softjar.se
Fri Aug 21 08:25:19 EDT 2015


On 2015-08-21 04:05, John Reagan wrote:
> On Thursday, August 20, 2015 at 5:43:42 PM UTC-4, JF Mezei wrote:
>
>>
>> Obviously, while in kernel mode, you can't be interrupted by an IO that
>> completes, right ? Or could an IO completing on another processor modify
>> memory areas that your kernel code is playing with ?
>>
>> But what about multiprocessor systems, can user mode code in one thread
>> modify a variable that is being used by your kernel code running on
>> another processor ?
>>
>
> Things like the IPL mechanism and spinlocks are used to guard against such things to serialize certain operations.  And there are MB instructions in various places of the OS to provide well-defined behavior.  That's why the instruction exists.

John, still a different thing. If we're talking about the dangers of not 
using colatile, then yes, the danger definitely also exists in kernel 
mode. As some have already pointed out, actual device controllers will 
modify memory without the compilers knowledge, so volatile is 
*neccesary* there too.
And yes, it is also relevant for multiprocessor systems. But user mode 
programs normally cannot cause this effect in the kernel, as switching 
to user mode in itself means you'll be leaving a block in the program, 
and user mode usually don't have write access to kernel memory. And 
definitely not in an asynchronous manner, from the point of view of the 
kernel.

	Johnny




More information about the Info-vax mailing list