Re: Explain this about threads




"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message
news:13fbad0h6nttqde@xxxxxxxxxxxxxxxxxxxxx
Jon Slaughter wrote:
[...]
Basically I'm trying to do synchronous communication with the parallel
port. I have the ability to use in and out which is supplied by a kernel
mode driver and dll wrapper.

I guess I'm curious at this point as to why you want to use this kernel
mode driver that provides you direct access to the ports? Windows has a
usable higher-level i/o API that should handle all the i/o timing and
buffering required. I'm not specifically aware of a managed code API, but
the unmanaged parallel port access via CreateFile, etc. ought to work I
would think.

Can you explain why it is the usual buffered i/o mechanisms are suitable
for your needs? I'm not sure it will lead to a specific solution, but it
would at least help us to understand the scenario better.


Because it uses a specific protocol AFAIK so you cannot use any deviced
attached to the port(only those deviced designed to communicate on it).

[...]
Then this will run about 100khz or so(on my machine). Now what if I need
to slow it down to 20khz? How can I do this without using spin waits but
still do it in a timely fashion?

I'm not aware of any non-spin-wait mechanism that will allow you to time
the interval between individual calls to out. The best you can do with
the mechanisms available is to ensure an _average_ data rate and even
there, without some kind of buffering support, you still have the problem
of having to not send data too fast.


huh? How can you ensure an average data rate but not ensure it will not be
to fast? Its very easy to ensure a maximum speed... its impossible to
ensure a mimimum speed.

If I do spinwait(100) then I'm guaranteed a atleast whatever maximum time
spinwait takes to execute.(assuming I kno how long it takes). The cpu cannot
execute any faster than its clock rate... Although maybe some of the
internal optimizations could, in theory, excute things a little faster.

Essentially any instruction executed that takes 1 cycle will always run with
a minimal time of 1/clock_speed. It can never be any faster except for those
possible optimizations the cpu does.

But spin-waits are potentially going to cause other problems that will
actually cause your implementation to perform worse. In some cases, it
might actually perform worse than just calling Sleep(1) between each call
to "out" (which itself, as you probably know, would kill performance if
you're looking for a 20khz sending rate).


My tests have shown thats its pretty good... atleast good enough for my
application.

Because I'm using clocked/synchronous communications with my external
device, it really utlimately doesn't matter about the speed or variations in
speed(except on a few devices that will time out). What I'm trying to
achieve is a way to send data at an average rate so this can be
quantitatively adjusted by the user. So if the user wants 20khz he will get
about 20khz and not 50khz or 5khz(on average).

If he decides to try it a little faster, like 21khz, then on average it will
be about 1khz faster(or atleast no slower, on average than 20khz).


If you have to use spin-waits, then I suppose you have to. But it would
be helpful to at least make sure you really have to. So far, it's not
clear why you have to (at least, not to me). Spin-waiting is bad enough
that it's definitely a last resort.


Sure... but if you can come up with a better way then I'm all ears. This is
the method used by all the programs that I am aware that are doing similar
stuff to what I need.

Although I have no idea how SPP mode works with clocked data for, say, a
printer. I'm not sure if they just bit-banged or what. Obviously the newer
modes get around this by having the hardware deal with it but they then
introduce there own protocols that do not work for me cause the devices I'm
attaching do not understand them.




.



Relevant Pages

  • Reference count issue with uart_close() on 2.6.16-2.6.20
    ... After that the serial port is no longer usable no matter what. ... Please find my kernel config and dmesg output below. ... # ACPI Support ... # PCI Hotplug Support ...
    (Linux-Kernel)
  • 6.0 Release kernel panic - page fault
    ... I'm experiencing kernel panics with 6.0 Release. ... port ... can't assign resources ... Additional ABI support: ...
    (freebsd-questions)
  • Random reboots on -CURRENT of 20031105
    ... Last night I cvsup-ed to -CURRENT and built world and kernel. ... pci0: <PCI bus> on pcib0 ... pci_cfgintr: 0:10 INTA BIOS irq 10 ... can't assign resources (port) ...
    (freebsd-current)
  • Re: How to tell if a firewall alert is suspicious or not
    ... > WHY this SBCGlobal DNS server would be contacting Adobe Acrobat on port ... They have to parts, a kernel and the userland, in which programs, which are ... With Internet Protocol and TCP it is so, that any network interface in the ... To initiate a TCP connection, first the server has to "listen" on a port. ...
    (comp.security.firewalls)
  • block driver
    ... The CF card is connected to pxa270 using VLIO interface, ... 0x87d2b810: out port ae002c a0 ... 0x87cd176c: RxInt in PIO mode.. ...
    (microsoft.public.windowsce.platbuilder)