Re: synchronize user & kernel spaces

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

 



Hi,

It's different from user space drivers.
I will give my algorithm bit.
Then you will get the point.

user write funcion
--------------------------------------------------------------
usr_write_dma( char *buf, int len )
{
   while( len > 0 ){
       if( len > DMA_BUF_MAX )
           ln = DMA_BUF_MAX
       else
           ln = len
       set data to struct dma_struct
       ioctl( fd, IOCTL_DMA, dma_struct )
       while(shared_variabl == 0);
       len -= ln;
       buf += DMA_BUF_MAX
   }
}
--------------------------------------------------------------

kernel space ioctl function
--------------------------------------------------------------
kern_ioctl()
{
   1.copy user data to dma buffer
   2. set pci registers( address, length etc. )
   3. start dma transfer
   return
}
--------------------------------------------------------------

interrupt routine
--------------------------------------------------------------
pci_interrupt()
{
   if( dma interrupt ){
       1. set length of data transferred to shared variable
       2. clear interrupt
       return
   }
}
--------------------------------------------------------------

This method works well.
but looping in the user function is not effective.
So I want to use wait/wakeup method there.
The way I suggest is as belows.

in user write function.
--------------------------------------------------------------
usr_write_dma( char *buf, int len )
{
   while( len > 0 ){
       if( len > DMA_BUF_MAX )
           ln = DMA_BUF_MAX
       else
           ln = len
       set data to struct dma_struct

	***** clear wake up count here *****

       ioctl( fd, IOCTL_DMA, dma_struct )

	***** sleep here *****

       len -= ln;
       buf += DMA_BUF_MAX
   }
}
--------------------------------------------------------------

in interrupt routine
****** wake up the above process ****

Is it possible to this method or could anyone please suggest
a method to do this?

I went through chapter 6 in ldd_3.
But it's all about kernel space blocking as I understood.

Thans.

Sumudu


Hi,

Are user space device drivers what you're looking for?

http://lwn.net/Articles/232575/
http://lwn.net/Articles/127698/
http://lwn.net/Articles/198202/
http://lwn.net/Articles/66829/

Thanks,

Rajat

[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