Re: LOCK prefix
From: Robert Wessel (spamtrap_at_crayne.org)
Date: 09/01/04
- Next message: rylan: "problem with hla compilation"
- Previous message: Moritz Tuerk : "Re: MBR Problems..."
- Next in thread: Robert Wessel: "Re: LOCK prefix"
- Maybe reply: Robert Wessel: "Re: LOCK prefix"
- Maybe reply: Ivan Korotkov : "Re: LOCK prefix"
- Maybe reply: IIJIMA Hiromitsu : "Re: LOCK prefix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 Aug 2004 22:47:08 +0000 (UTC)
" Bern" <spamtrap@crayne.org> wrote in message news:<41343ece$1@news.starhub.net.sg>...
> i got another question:
> what if two processors simultaneously write/read to the same IO port?
>
> is there some synchronisation mechanism?
In short, not much. Architecturally, only aligned I/O accesses have
well defined semantics, although unaligned one (despite being of
rather limited use) do perform more-or-less as expected on all
implementations I'm aware of.
The aligned I/O transactions are basically atomic, however, although
there's no ordering defined between the CPUs. But if you have more
than one processor simultaneously hitting an I/O port without proper
synchronization, you're probably looking at a blue-screen (insert your
favorite operating system's kernel panic display here) in short order.
Yes, there are a few exceptions to that, but in general access to
device registers cannot be done from more than one thread
simultaneously (whether on a single CPU or many). Consider, for
example, what would happen if you had two processors trying to read
data from a 8250 style serial port. Both might look at 0x3fd
(assuming COM1) and notice that there's a byte available, then try to
read that byte from 0x3f8. One will succeed, the other read garbage.
While that example probably won't lead to a blue-screen, it will lead
to corrupted data. Imagine corrupting data on the disk controller.
The point is that you usually need to make special provisions for
appropriate synchronization in your device driver, usually with some
assistance from the OS. This can be simple or complex, depending on
how much concurrency you want to support for the device and what
facilities the OS offers. For example, in some OSs you can tell the
OS to never reentrantly call your driver, even for interrupts.
Problem solved. For another driver, perhaps for a disk subsystem, you
might want to be able to handle many concurrent requests from
applications, plus multiple devices, plus multiple outstanding
requests per device. In that case, you have to deal with the
synchronization issues at a much more detailed level.
Most I/O devices these days don't implement any I/O ports expect for
compatibility purposes (it's all memory mapped now). But that doesn't
really change anything as far as synchronization of accesses to actual
hardware goes.
- Next message: rylan: "problem with hla compilation"
- Previous message: Moritz Tuerk : "Re: MBR Problems..."
- Next in thread: Robert Wessel: "Re: LOCK prefix"
- Maybe reply: Robert Wessel: "Re: LOCK prefix"
- Maybe reply: Ivan Korotkov : "Re: LOCK prefix"
- Maybe reply: IIJIMA Hiromitsu : "Re: LOCK prefix"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|