RS Int/sec Period 3210 - - 0000 none none 0001 256 3.90625 ms 0010 128 7.8125 ms 0011 8192 122.070 Micros 0100 4096 244.141 Micros 0101 2048 488.281 Micros 0110 1024 976.562 Micros 0111 512 1.93125 ms 1000 256 3.90625 ms 1001 128 7.8125 ms 1010 64 15.625 ms 1011 32 31.25 ms 1100 16 62.50 ms 1101 8 125.0 ms 1110 4 250.0 ms 1111 2 500.0 ms
> I was able to do some testing today. I am working with a WinSystems
> EBC-C384-D2 <http://sbc.winsystems.com/products/EBC-C384-D.cfm>. I wrote
> the square wave test program in assembler and set the delays to produce a
> 40kHz waveform. Initial stability testing shows a big hit when the RTC
Are you really trying to do accurate timing without a HW timer ? This is
really strange and sound like the "good old times" when cycle-counting was
used to get (at that time) µs delays.
Cycle counting on a x86 will _not_ work!
But on a 1.8GHz CPU you should be able to run high speed interrupts with
only a few ns of jitter.
And if you use one core for the interrupt only, maybe without jitter.
Regarding BMOS, you might want to make sure, the keyboard interrupt does
not wakeup all core but only the one with the command-line.
> interrupt fires. I am using MS-DOS 6.22 as my standard benchmark.
> BareMetal's RTC interrupt takes 5x longer than DOS's. This was not good.
Longer in which regard ?
> Taking heed of your comments below, I masked off the interrupts using the
> CLI instruction just before entering the main loop. Now BareMetal proves to
> be 2x more stable than DOS running the same code. Very interesting...
>
> Will shutting off the interrupts for long periods (e.g. seconds, minutes,
> or even hours) lead to any problems for the OS?
=> no keyboard interrupts !
Just a side note: On a ARM7TDMI with 50MHz we could produce a 20kHz signal
w/o any jitter !
--
42Bastian
Hi Fred
Are you really trying to do accurate timing without a HW timer ? This is really strange and sound like the "good old times" when cycle-counting was used to get (at that time) µs delays.
Cycle counting on a x86 will _not_ work!
But on a 1.8GHz CPU you should be able to run high speed interrupts with
only a few ns of jitter.And if you use one core for the interrupt only, maybe without jitter.
Regarding BMOS, you might want to make sure, the keyboard interrupt does
not wakeup all core but only the one with the command-line.
> interrupt fires. I am using MS-DOS 6.22 as my standard benchmark.
> BareMetal's RTC interrupt takes 5x longer than DOS's. This was not good.Longer in which regard ?
> Taking heed of your comments below, I masked off the interrupts using the
> CLI instruction just before entering the main loop. Now BareMetal proves to
> be 2x more stable than DOS running the same code. Very interesting...
>
> Will shutting off the interrupts for long periods (e.g. seconds, minutes,
> or even hours) lead to any problems for the OS?=> no keyboard interrupts !
Just a side note: On a ARM7TDMI with 50MHz we could produce a 20kHz signal
w/o any jitter !
--
42Bastian
>> Are you really trying to do accurate timing without a HW timer ? This
>> is really strange and sound like the "good old times" when cycle-counting
>> was used to get (at that time) µs delays.
>>
> No we plan to poll a hardware timer for expiration. We want to make sure
> that when the timer edge goes high, we are there to respond.
Why poll ? Why not setup an interrupt ? It is by far more accurate then
polling.
>> Cycle counting on a x86 will _not_ work!
>>
>> Why do you say this? Is it because Intel keeps adding "features" to the
> architecture. Things like the SMI, Power Management, Legacy USB support? I
> can turn all these features off.
It has nothing to do with the USB or SMI. Maybe with power management. But
for sure with the pipelines, out of order execution and the cache.
> But on a 1.8GHz CPU you should be able to run high speed interrupts with
>> only a few ns of jitter.
>>
>> And if you use one core for the interrupt only, maybe without jitter.
>>
>> I hope to see this someday, then I can leave all the interrupts enabled,
> but, I have not seen it yet.
>
>
>> Regarding BMOS, you might want to make sure, the keyboard interrupt does
>> not wakeup all core but only the one with the command-line.
>>
>
> I need to understand the architecture better. I don't know how the
> interrupts are wired to the system. I don't understand how multi-core
> works. I am looking for a good ATOM and/or Multicore Intel architecture
> book... Maybe the Intel Press book "Break Away with Intel® Atom™ Processors"??
> I think I will get a copy...
If I understand the code correctly (Ian please correct me) from init_64.s
mov rcx, 8 ; Enable RTC
mov rax, 0x0100000000000928 ; Lowest priority
; mov rax, 0x28 ; Handled by APIC ID 0 (BSP)
the RTC interrupt is send to the CPU with the lowest cpu.
Try removing the comment, then let your "toggle-code" run on AP.
This should give you the best values you can get even with interrupts
enabled, since the interrupts are handled by the BSP.
>>> interrupt fires. I am using MS-DOS 6.22 as my standard benchmark.
>>> BareMetal's RTC interrupt takes 5x longer than DOS's. This was not good.
>>
>> Longer in which regard ?
>>
> Longer in regards to my measurement system. I have a second processor
> incrementing a variable as fast as it can when the waveform is low and
> another when it is high. I keep track of the average counts ant the max
> counts. The BareMetal max count is always approx 5x bigger than than the
> DOS max count when interrupts are enabled. And always approx 2x smaller
> than DOS when interrupts are disabled.
Excuse me, but this sounds strange and not correct way to measure such thing.
If you want an accurate wave-form (which is you max. frequency?) a simple
PIC can achieve such. No need for the big iron.
Todays micro-controller (nearly) all come with HW timers and PWM output.
Anyway, if you want to use the big iron, I strongly suggest to use interrupts.
> I was surprised to see that with the CLI instruction asserted, the keyboard
> interrupt still worked!
Do you use CLI in your program ? If it runs on the AP, it is clear. You
are disabling interrupts only on one core. KBD is already directed to the
BSP, and RTC will because on the AP interrupts are disabled.
In both BareMetal and in DOS. I could press Esc in
> BM and Ctrl-Alt-Del in DOS and the system rebooted. Maybe the keyboard is
> connected to a non-maskable interrupt in the atom??
Don't know about DOS. Does it handle multiple cores ?
>> Just a side note: On a ARM7TDMI with 50MHz we could produce a 20kHz signal
>> w/o any jitter !
>>
>> Maybe the days of the PC based control system is over :-( ?
For sure when it comes to such simple jobs. It is always the question how
much work needs to be done in the Core (heavy floating point math) and how
much on the peripherals (toggle I/Os, serial, ethernet).
For example, a PowerPC MPC5121@400MHz can handle TCP/IP on a 100MB
Ethernet as quick as an Core2 D...@2.4GHz. => No benefit to use the more
power consuming Core2 Duo.
Just a note: The 1.8GHz are not good for comparing. You need to know the
bus speed.
Just check how fast you can toggle an I/O pin on a x86 and compare it with
any uC around.
Just my 2cents
--
42Bastian
cmp byte [os_show_sysstatus], 0je rtc_no_sysstatuscall system_status ; Show System Status information on screenrtc_no_sysstatus:
> typing and running commands affects the timing of the wave...
The keyboard interrupt sends an interrupt to all cores.
Try replacing
call os_smp_wakeup_all ; A terrible hack
by
mov al, 0
call os_smp_wakeup
to wakeup only the BSP in interrupt.asm .
--
42Bastian
Hi Fred>> Are you really trying to do accurate timing without a HW timer ? This
>> is really strange and sound like the "good old times" when cycle-counting
>> was used to get (at that time) µs delays.
>>
> No we plan to poll a hardware timer for expiration. We want to make sure
> that when the timer edge goes high, we are there to respond.Why poll ? Why not setup an interrupt ? It is by far more accurate then
polling.
>> Cycle counting on a x86 will _not_ work!
>>
>> Why do you say this? Is it because Intel keeps adding "features" to the
> architecture. Things like the SMI, Power Management, Legacy USB support? I
> can turn all these features off.It has nothing to do with the USB or SMI. Maybe with power management. But
for sure with the pipelines, out of order execution and the cache.
> But on a 1.8GHz CPU you should be able to run high speed interrupts with
>> only a few ns of jitter.
>>
>> And if you use one core for the interrupt only, maybe without jitter.
>>
>> I hope to see this someday, then I can leave all the interrupts enabled,
> but, I have not seen it yet.
>
>
>> Regarding BMOS, you might want to make sure, the keyboard interrupt does
>> not wakeup all core but only the one with the command-line.
>>
>
> I need to understand the architecture better. I don't know how the
> interrupts are wired to the system. I don't understand how multi-core
> works. I am looking for a good ATOM and/or Multicore Intel architecture
> book... Maybe the Intel Press book "Break Away with Intel® Atom™ Processors"??
> I think I will get a copy...If I understand the code correctly (Ian please correct me) from init_64.s
mov rcx, 8 ; Enable RTC
mov rax, 0x0100000000000928 ; Lowest priority
; mov rax, 0x28 ; Handled by APIC ID 0 (BSP)the RTC interrupt is send to the CPU with the lowest cpu.
Try removing the comment, then let your "toggle-code" run on AP.
This should give you the best values you can get even with interrupts
enabled, since the interrupts are handled by the BSP.
>>> interrupt fires. I am using MS-DOS 6.22 as my standard benchmark.
>>> BareMetal's RTC interrupt takes 5x longer than DOS's. This was not good.
>>
>> Longer in which regard ?
>>
> Longer in regards to my measurement system. I have a second processor
> incrementing a variable as fast as it can when the waveform is low and
> another when it is high. I keep track of the average counts ant the max
> counts. The BareMetal max count is always approx 5x bigger than than the
> DOS max count when interrupts are enabled. And always approx 2x smaller
> than DOS when interrupts are disabled.Excuse me, but this sounds strange and not correct way to measure such thing.
If you want an accurate wave-form (which is you max. frequency?) a simple
PIC can achieve such. No need for the big iron.Todays micro-controller (nearly) all come with HW timers and PWM output.
Anyway, if you want to use the big iron, I strongly suggest to use interrupts.
> I was surprised to see that with the CLI instruction asserted, the keyboard
> interrupt still worked!Do you use CLI in your program ? If it runs on the AP, it is clear. You
are disabling interrupts only on one core. KBD is already directed to the
BSP, and RTC will because on the AP interrupts are disabled.
In both BareMetal and in DOS. I could press Esc in
> BM and Ctrl-Alt-Del in DOS and the system rebooted. Maybe the keyboard is
> connected to a non-maskable interrupt in the atom??Don't know about DOS. Does it handle multiple cores ?
>> Just a side note: On a ARM7TDMI with 50MHz we could produce a 20kHz signal
>> w/o any jitter !
>>
>> Maybe the days of the PC based control system is over :-( ?For sure when it comes to such simple jobs. It is always the question how
much work needs to be done in the Core (heavy floating point math) and how
much on the peripherals (toggle I/Os, serial, ethernet).
For example, a PowerPC MPC5121@400MHz can handle TCP/IP on a 100MB
Ethernet as quick as an Core2 D...@2.4GHz. => No benefit to use the more
power consuming Core2 Duo.
Just a note: The 1.8GHz are not good for comparing. You need to know the
bus speed.
Just check how fast you can toggle an I/O pin on a x86 and compare it with
any uC around.
Just my 2cents
--
42Bastian
>> Why poll ? Why not setup an interrupt ? It is by far more accurate then
>> polling.
>>
> We are polling because we are trying to get rid of all the latencies. Intel
> has a whitepaper Microcontroller to
> Intel® Architecture Conversion Programmable Logic Controller (PLC) Using
> Intel® Atom™ Processor<http://download.intel.com/design/intarch/papers/323213.pdf>.
> It shows on page 19 a best worst case latency of 3.56 uS using CentOS with
> kernel 2.6.18. Embedded Menlow platform with 1.6GHz CPU. We would like to
> be sub-microsecond worst case (Maybe this latency is because of the linux
> OS?).
This is pretty sure related to Linux. Linux is and was never an RTOS and
does lock out interrupts for a quite long time in the kernel.
Check out, if you can get figures for QNX or VxWorks on x86.
Why? Because a 72MHz ARM CPU is already at 1us interrupt latency running
my companies RTOS!
A 400MHz-PowerPC is arround 500ns!
> OK I understand. I saw an online presentation last year on how you really
> can't know what is going on in the processor anymore. All this branch
> prediction etc, leads to very unpredictable time of execution.
Right.
>>>> Regarding BMOS, you might want to make sure, the keyboard interrupt does
>>>> not wakeup all core but only the one with the command-line.
>>>>
>>>
>>> I need to understand the architecture better. I don't know how the
>>> interrupts are wired to the system. I don't understand how multi-core
>>> works. I am looking for a good ATOM and/or Multicore Intel architecture
>>> book... Maybe the Intel Press book "Break Away with Intel® Atom™
>> Processors"??
>>> I think I will get a copy...
I suggest reading the (x2)APIC chapters in the
<http://www.intel.com/content/dam/doc/specification-update/64-architecture-x2apic-specification.pdf>
and in the 64-ia-32-architectures-software-developer-manual-325462.pdf
>> Do you use CLI in your program ? If it runs on the AP, it is clear. You
>> are disabling interrupts only on one core. KBD is already directed to the
>> BSP, and RTC will because on the AP interrupts are disabled.
>>
>> I don't understand this yet. What is the AP and the BSP? I see Intel has a
> MultiProcessor Specification that explains these terms. I will need to read
> it.
It took me a while to understand Intels naming: BSP - BootStrapProcessor,
AP - ApplicationProcessor.
>> Yes I have seen this. For example: I have seen that an FPGA can toggle an
> IO really,really fast but, try to add a processor core to the FPGA, perform
> floating point math in it and then manipulate the IO based upon the math
> results. Things slow down quite a bit. **This observation was made in early
> 2000 so maybe FPGA processor cores are better now.
I am not sure. Most Soft-Cores do not have floating point.
When it comes to FPU, there are very few real micro controllers.
Mostly they only have single precision floating point.
--
42Bastian
Oh yeah big improvement. I can't even see the RTC fire anymore. Now BareMetal is 2x more stable than DOS out of the box!
I seem to have an issue with my build of the OS though... I checked out ReturnInfinity-BareMetal-OS-637a3bb.zip, built with modified interrupt.asm, compiled using nasm kernel64.asm -o kernel64.sys. The problem is: When I run the program, it starts execution and keeps running but the command prompt immediately returns with the following message (spacing is messed up as shown below):
Co mm an d o r p r o g r a m n o t f o u n d d
> >
The square wave continues to run "in the background" as I type and execute commands in the BMOS CLI. Just garbage comes back: Stuff like:
AT16 > > dir
Command or program nCootm mfo u n d or program not found
>>
>
>
typing and running commands affects the timing of the wave...
I built using Debian 6.0 using the packaged NASM version 2.08.01 compiled on June 2 2010.
Any ideas why my build is so messed up?
Thanks,
Fred
On , Ian Seyler wrote:
I wonder if it is because of my build environment or my test hardware... I will try a few different combinations to see if I can figure out what is going on. What Linux distro are you developing in? I see you are using QEMU. I am using VBOX.There is nothing special attached to the ports just a PC104 digital IO board.
FredBTW: There is a small bug in my test program. The second out that forms the bottom of the square wave is using ax by accident. It should be using al.
> build environment. I just need to know what to use to get a solid build.
> Anybody?
Maybe you should wind back to the releases of pure64 and bmos ?! Not the
GIT checkout.
--
42Bastian