--- In "moonlightshard" <> wrote:
>
> --- In "charliem_1216" <charliem_1216@> wrote:
> >
> > --- In "moonlightshard" <moonlightshard@> wrote:
> > >
> > > --- In Jim Jackson <jj@> wrote:
> > > >
> > > >
> > > > [don't top post]
> > >
> > > Ok
> > >
> > > > Are you trying to write an IRQ handler in userspace?
> > > > If so, give up straight away. You handle IRQ in the kernel. Phil did it
> > > > in a kernel module which is inserted into the kernel and runs in kernel
> > > > "space".
> > >
> > > Yes, I suppose we were. We have given it up.
> > >
> > > > Try just commenting the include out and try recompiling. I've checked
> > > > my source and it's commented out.
> > >
> > > Thanks, we commented the include out and we were able to generate adc.o.
> > > However, when we use /sbin/insmod command, it complains about a mismatch
> > > in kernel version:
> > >
> > > Using /root/adc.o
> > > insmod: kernel-module version mismatch
> > > /root/adc.o was compiled for kernel version 2.4.26
> > > while this kernel is version 2.4.26-ts11.
> > >
> > > We downloaded the kernel source for version 2.4.26-ts11 and used it to
> > > compile, but it's still giving us this error.
> >
> > If the error is exactly the same, then you did not properly point to the
> > -ts11 kernel source when (re)-compiling adc.o. Make sure you are inserting
> > the new module you just compiled, not the old one.
> >
> > >
> > > Any suggestions?
> > >
> >
> > Yes, take a look at:
> > http://lwn.net/Kernel/LDD2/
> >
> > It helps a great deal when learning to develop linux kernel device drivers.
> > There is a newer one (LDD3) that is for 2.6 kernels; LDD2 is for 2.4
> > kernels.
> >
> > > Thanks
> > >
> >
> > regards, ......... Charlie
> >
>
> Hi again,
>
> We were able to load the kernel module and use functions written in this
> module for our program. However, we needed a sample rate of 1kHz, and we were
> having trouble sampling at a constant frequency for any frequency above 1Hz.
>
> We don't beleive there are any errors in our program, and in testing this we
> tried to test Phil's kernel simply with the kernel comands he set up. We set
> our desired sampling rate using a ECHO command that came with the module, and
> the module, using a interrupt routine, wrote the sampled data to a dev/adc1.
> Then we tried to read the sampled data using cat dev/adc1. The output
> displays at a fast rate(as 1kHz should be), but pauses about every half a
> second, and keeps going at the same paste.
>
> We would like to know why this is happening, and how to use Phil's code to
> achieve a constant 1kHz sampling rate.
>
> Thanks
>
Hello,
The module is actually sampling at 1kHz (if that is what you set it to), it is
simply gathering together a number of samples and returning them back to the
userspace (via the 'cat' command or however you receive it) at longer
intervals. The idea is that there is a large overhead in transistioning between
kernelspace and userspace, and reducing the number of transistions reduces the
load on the system. In my particular application, the only 'time' critical part
was to ensure that the sample was taken at regular intervals, every 1ms for a
sample rate of 1kHz. It did not matter if my userspace program wasn't 'seeing'
those samples until maybe 0.5s later.
The other point is also the fact that you can't guarentee when your userspace
code will be scheduled to run. If you were hoping that the kernel module would
be able to return 1 data point every 1ms to your userspace program, you would
find the same issues that you get if you try and 'sleep' for 1ms in userspace
and the sleep still takes 10ms. You have to deal with the Linux 10ms tick clock
everywhere is userspace.
So this is everything I did for particular application, you have to review your
own application and determine everything that is time critical and that would
need to go in the kernel module IRQ handler too. You just have to be very
careful about what does go into it as it needs to execute rather quickly if you
are trying to get high sample frequencies out of it.
Hope some of this makes sense, let me know if it doesn't.
Cheers
Phil
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|