Re: atomic io

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:
> On Thu, 2005-03-31 at 12:18 -0800, john bogus wrote:
> > I have seen various examples in the kernel code
> where
> > a bit is set / cleared in an output port by code
> like
> > 
> > writeb((readb(PBDDR)) & PORTB_PIN0_SDA_INPUT,
> PBDDR);
> > 
> > or 
> > 
> > uiRegTemp = inl(GPIO_PADDR);
> > outl( uiRegTemp | 0x80, GPIO_PADDR );
> > 
> > 
> > This code is not atomic (and in some examples I am
> > guessing it should be).  Are there fuctions
> similar to
> > set_bit, clear_bit, change_bit which work on I/O? 
> if
> > not what is the recomended way to do this?
> 
> this is not how pci busses and such work.
> THe pci bus only has read and write primitives on 8
> 16 and 32 bit sizes.
> No bit level ops.
> 
This is often used in embedded applications, in my
case I am using an EP9301 processor.  As you indicated
it does not have bit operations.

It is often the case that different drivers will use
bits on the same port. To get bit ops you read the
port change the bit and write the result back.  The
problem with this is that if the operation is
interrupted between the read and the write and the
port is changed by another process, the change by the
other process will be lost when it returns control to
this process, thus the need for atomic operations.

Normally I would just disable/enable interrupts around
the read/write, but this seems to be strongly
discouraged in linux.



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Personals - Better first dates. More second dates. 
http://personals.yahoo.com


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux