Re: OS Question
- From: "David Craig" <drivers@xxxxxxxxxx>
- Date: Mon, 12 May 2008 17:14:25 -0700
I should have said that in user mode you might be able to keep control in
one thread by going to realtime, but it is certain it will always work.
Programming for multiprocessor is always multithread safe, so do it in a way
it will be safe for SMP. Many current CPUs are SMP with multiple cores and
even the old hyperthreading simulates SMP but it was not quite as good as
having real multiple cores in a system. There are also tricks with
processor affinity in user mode that can help, but that type of code can be
fragile and hard to maintain - so why do it! Use a driver and spinlocks to
control access to low level resources. To protect data in user mode just
use semaphores, mutexes, and/or events as appropriate. Since this is not a
user mode code group, it is not really a good question for this newsgroup if
that is your target.
"David Craig" <drivers@xxxxxxxxxx> wrote in message
news:ubwXsmItIHA.1316@xxxxxxxxxxxxxxxxxxxxxxx
Also the 'multithreading' can easily be fixed just by raising your IRQL to
dispatch level. In user mode you might be able to increase priority
enough to get control. However, this won't fix the multiprocessor
problems. In kernel mode only spinlocks can be used to control access to
data or hardware so that only one thread on one processor can have
exclusive control.
"m" <m@xxx> wrote in message news:et5i0AItIHA.4544@xxxxxxxxxxxxxxxxxxxxxxx
More importantly, the 'protection' that this scheme offers does not exist
for a period of time when the API call is executing and so any 'rogue'
code can just write to the page then and it will be trashed.
Maxim's situation could be remedied by handling the second exception or
using locks on the APIs to prevent concurrent access to pages.
"Maxim S. Shatskih" <maxim@xxxxxxxxxxxxxxxx> wrote in message
news:e%23jB2tHtIHA.4912@xxxxxxxxxxxxxxxxxxxxxxx
Can you explain? what is not compatible with multithreading? If there
is
- 2 threads wants to write access the same data
- first gain the access
- second thread gains the access
- first thread does its work and returns
- on return, the data is marked back as read-only
- then second thread try to do work, and the data is read-only, a crash
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@xxxxxxxxxxxxxxxx
http://www.storagecraft.com
.
- Follow-Ups:
- Re: OS Question
- From: Hugo gleaves
- Re: OS Question
- References:
- OS Question
- From: Hugo gleaves
- Re: OS Question
- From: Alexander Grigoriev
- Re: OS Question
- From: Hugo gleaves
- Re: OS Question
- From: Maxim S. Shatskih
- Re: OS Question
- From: Hugo gleaves
- Re: OS Question
- From: Maxim S. Shatskih
- Re: OS Question
- From: m
- Re: OS Question
- From: David Craig
- OS Question
- Prev by Date: Re: OS Question
- Next by Date: Re: kernel mode proxy driver
- Previous by thread: Re: OS Question
- Next by thread: Re: OS Question
- Index(es):
Relevant Pages
|