PDA

View Full Version : thunderbolt hardware interrupt




MacMen
Jan 17, 2012, 04:31 AM
Does thunderbolt have a hardware interrupt?
Hardware interrupt: http://en.wikipedia.org/wiki/Interrupt
I need this to log data from a GPS device simultaniously with the time and another measurement. Couldn't find it anywhere on the www.



Soulstorm
Jan 17, 2012, 04:34 AM
Does thunderbolt have a hardware interrupt?
Hardware interrupt: http://en.wikipedia.org/wiki/Interrupt
I need this to log data from a GPS device simultaniously with the time and another measurement. Couldn't find it anywhere on the www.

I don't know, however, keep in mind that thunderbolt is actually DisplayPort and PCI Express put together. Maybe documentation on PCI Express will help you.

On and... you should post this in another forum category. It's actually a question about micro controller programming and stuff like that, and it is unlikely that you find help in this section of macrumors.

MacMen
Jan 17, 2012, 09:01 AM
Thanks for your respond. I will try to find it in PCI Express documentation.
So, is there any (other) port in a Macbook pro (2011) 15" that has hardware interrupt?

I couldn't find how to move a thread using the search functionality. Is this something a mod should do?

robbieduncan
Jan 17, 2012, 09:37 AM
I couldn't find how to move a thread using the search functionality. Is this something a mod should do?

Only Mods/Admins/Gods can move threads. I've moved it to Mac Programming for the moment as this is probably the best place.

Answering the question it seems likely that any device on the PCI bus can generate interrupts (http://www.yashks.com/2011/01/interrupts-basics/). This can include USB devices connected via a USB controller on such a bus. Whether the device declares that it generates interrupts is going to be down to the driver I suspect. It may be possible to generate the "hardware" interrupt via software if you had a dummy device driver. But I'm not really sure on that.

gnasher729
Jan 17, 2012, 11:47 AM
Does thunderbolt have a hardware interrupt?
Hardware interrupt: http://en.wikipedia.org/wiki/Interrupt
I need this to log data from a GPS device simultaniously with the time and another measurement. Couldn't find it anywhere on the www.

1. Is the GPS connected to a Thunderbolt port? If not, how are hardware interrupts on Thunderbolt going to help you?

2. What makes you think that any modern OS would just let you access hardware interrupts?

3. GPS devices are typically just plain old serial devices, encapsulated in USB. So all you do is figure out how to read from a serial device, and when you read the data, you ask the OS what the time is.

You are making the typical mistake of not asking about you actually want to achieve, but asking about a (in this case rather far fetched) idea how you could do this.

ChOas
Jan 17, 2012, 12:31 PM
[...]

You are making the typical mistake of not asking about you actually want to achieve, but asking about a (in this case rather far fetched) idea how you could do this.

I couldn't agree more, this is a case of the XY problem;

http://www.perlmonks.org/?node_id=542341

(sorry,by work a Perl programmer)

MacMen
Jan 19, 2012, 08:34 AM
First of all, thanks for your reply. To answer your questions, gnasher729:

1. Is the GPS connected to a Thunderbolt port? If not, how are hardware interrupts on Thunderbolt going to help you?
- The idear is to connect it to thunderbolt yes, as usb and firewire do not have hardware interrupt, thunderbolt is the only option left.

2. What makes you think that any modern OS would just let you access hardware interrupts?
- Simple. The OS cannot decide about priority's set in the hardware. Hardware interrupts are in the microarchitecture. Hydrographic surveyors buy laptops with oldfashioned serial ports for this very hardware interrupt (that's why I was wondering if Thunderbolt/any other MacBook Pro port does the same, as I will use it for the same purpose and I don't like to buy a pc to do it).

3. GPS devices are typically just plain old serial devices, encapsulated in USB. So all you do is figure out how to read from a serial device, and when you read the data, you ask the OS what the time is.
- That's another solution, probably better, but this question is about real time logging. But, for logging real time, without hardware interrupt, the data stream might be 'paused' by the software, as the software can prioritize this, resulting in very smal delays, causing a time mismatch.

You are making the typical mistake of not asking about you actually want to achieve, but asking about a (in this case rather far fetched) idea how you could do this.
- I agree, it's because I'm not only interested in X but also in Y, even if Z is better.

The question is still open: does Thunderbolt have hardware interrupt?
Meaning, is it in the microarchitecture or not.

jettoblack
Jan 19, 2012, 11:15 AM
When you say "for logging real time, without hardware interrupt, the data stream might be 'paused' by the software" we're talking about fractions of a millisecond in most cases. A modern 2GHz processor ticks every 0.0000000005 seconds. How much accuracy do you need?

Hardware interrupts were mostly an issue back in the days of unbuffered serial communications, when even a tiny delay on the host could result in data loss because there was nothing to hold the data until the host was ready. With modern computers and buffered ports it is much less important, unless your definition of "real-time" is in the sub-millisecond range, and most GPS receivers don't recalculate the position that fast anyway.

If you're trying to get 1cm military GPS accuracy on a rocket or something like that, then hardware interrupt might be necessary. But for anything else, I think the internal delays within the GPS device (e.g. between the GPS receiver, the CPU, and the USB/serial/etc. interface) are going to be orders of magnitude higher than any delay from the host computer polling the USB port.

ScoobyMcDoo
Jan 19, 2012, 11:41 AM
I'm not really sure if it provides a hardware interrupt or not, but it appears that time sync is the purpose for your use of an interrupt signal. The TB literature claims that the protocol has a time synchronization scheme with an 8 nanosecond precision. Maybe that will help?

MacMen
Jan 19, 2012, 02:16 PM
I'm not really sure if it provides a hardware interrupt or not, but it appears that time sync is the purpose for your use of an interrupt signal. The TB literature claims that the protocol has a time synchronization scheme with an 8 nanosecond precision. Maybe that will help?

It certainly means it won't be necessary to buy a pc with serial port, TB can do it. I couldn't find anything about interruption, maybe nowadays it's not significant anymore.

MacMen
Jan 19, 2012, 02:30 PM
Hardware interrupts were mostly an issue back in the days of unbuffered serial communications, when even a tiny delay on the host could result in data loss because there was nothing to hold the data until the host was ready. With modern computers and buffered ports it is much less important, unless your definition of "real-time" is in the sub-millisecond range, and most GPS receivers don't recalculate the position that fast anyway.

If you're trying to get 1cm military GPS accuracy on a rocket or something like that, then hardware interrupt might be necessary. But for anything else, I think the internal delays within the GPS device (e.g. between the GPS receiver, the CPU, and the USB/serial/etc. interface) are going to be orders of magnitude higher than any delay from the host computer polling the USB port.

That would indeed explain why I couldn't find anyting about an interrupt, it simply is not an issue for most purposes nowadays.
However, for hydrographic purposes (I'm a hydrography student) one centimeter (sometimes) matters, as the price for, for example, dredging is per kubic metres (very very expensive kubic metres), wich means all mis-measurements weigh to the power 3 (volume, over a big area). I'm not sure how much it matters, I'll try to find out, as, as meantioned before why surveyors still want serial ports with hardware interrupt on their laptops, a relic or ... . But that's another discussion. So, everybody thanks for their respond and help.

gnasher729
Jan 19, 2012, 09:45 PM
I seriously doubt you have looked at how GPS devices actually work.

GPS chips communicate via a serial port, usually encapsulated within USB. They communicate at the lightning speed of at most 115,200 bit per second, or about 12,000 byte per second, so a typical message will take several milliseconds from start to end. So your worries about losing time are already hilarious. Worse, you don't know how much time the device spends from determining its location to the time when it sends it.

However, every message from a GPS device contains a time stamp. The GPS device doesn't just send you the location, but the location and the exact time when the measurement was taken. And why on earth would it matter if you don't record the time of measurement exactly? The stuff that you are dredging isn't exactly moving at high speed, is it? I suppose it is actually lying there absolutely still, and it will be in exact the same place an hour later.


If you're trying to get 1cm military GPS accuracy on a rocket or something like that, then hardware interrupt might be necessary.

Actually, any civil GPS device (that is any device the OP could possibly buy) will refuse to report anything if it determines that the GPS is moving above a certain speed and/or above a certain height, exactly to make the use in rockets impossible.

MacMen
Jan 20, 2012, 02:15 AM
The bottleneck of the system is in the computer, in the port, isn't it?... Not in the GPS.
The seabed isn't moving, correct, but the survey vessel is, quite fast sometimes...

Maybe you could explain why serial port is prefered above usb by hydrographers? Are all hydrographers silly old-fashioned persons or might there be a reason they do so.

Basically, I don't wish to be forced to use Dell-laptops with serial ports in my work and want to know someting about this hardware interrupt the serial ports can generate and the most likely port a mac has that can do the same job, wich I think is Thunderbolt, see ScoobyMcDoo's post. But as I said, this is another discussion, one I have to have with some hydrographers sometime.

gnasher729
Jan 20, 2012, 05:34 AM
The bottleneck of the system is in the computer, in the port, isn't it?... Not in the GPS.
The seabed isn't moving, correct, but the survey vessel is, quite fast sometimes...

So what does it matter that the vessel is moving? The GPS device receives signals from at least four satellites. It determines when exactly each signal was received with a resolution of about ten nanoseconds. It has information about the exact orbit of each satellite with a high precision. With this information, it calculates three coordinates in space and one in time; the coordinates in space are mapped to coordinates on the earth's surface within a few meters, the coordinates in time have a precision of a few nanoseconds. The GPS knows "I was exactly at this point, at this time" and that's what it sends out. It doesn't matter one bit whether the ship is moving. We are talking about 10 ns here. Your survey vessel won't move a thousandth of a millimetre in 10 ns.

So if all you want is to use a GPS that has a serial port, buy a serial-port-to-USB adapter which should only cost you maybe ten or twenty dollars.
Correction: 2.10 on ebay.co.uk

The reason why serial ports need hardware interrupts is that in the early 80's the processor had to grab bytes from the serial port quick enough (once a millisecond) or they would be lost, then the serial port chips got buffers for 16 bytes so you would lose data less often, and then they got a hardware interrupt so that the OS would be told that data is available and didn't have to check hundred times a second. That hardware interrupt with a decent sized buffer is implemented inside that 2.10 serial-to-USB adapter.

KnightWRX
Jan 20, 2012, 08:40 AM
Just use the standard USB API, no need to go so quite low-level.

If you're determined to go so low level, you will need to look into using something in kernel space. Looking for a "Thunderbolt" interrupt is wrong, the OS will emulate the RS-232 port required over USB or whatever and that is what you'll be talking to.

If you're really serious about "real-time" programming, I'd suggest looking into a "real-time" OS like VxWorks or looking into Real Time Linux :

https://rt.wiki.kernel.org/

Again, to get the level of accuracy and control you want, you'll probably not be able to run from userspace.

But you really need to ask yourself, in light of gnasher's information about GPS units, if all of this grief is really necessary, or just some hacker fetish you're trying to fufill. Good luck.

gnasher729
Jan 20, 2012, 09:03 AM
But you really need to ask yourself, in light of gnasher's information about GPS units, if all of this grief is really necessary, or just some hacker fetish you're trying to fufill. Good luck.

For some more information, check this website:

http://www.gpsinformation.org/dale/nmea.htm

Even though it is a bit outdated, it shows the principles. GPS devices actually transmit messages of up to 82 bytes at 4,800 baud! Which means a message takes up to 170 milliseconds, and a single byte over two milliseconds to transmit. So in the very best case, the computer will know where the GPS was 170 milliseconds ago.

chown33
Jan 20, 2012, 10:10 AM
Basically, I don't wish to be forced to use Dell-laptops with serial ports in my work and want to know someting about this hardware interrupt the serial ports can generate and the most likely port a mac has that can do the same job, wich I think is Thunderbolt, see ScoobyMcDoo's post. But as I said, this is another discussion, one I have to have with some hydrographers sometime.

Unless you're planning to write a device-driver that interfaces to Thunderbolt, I don't see how Thunderbolt is relevant, even if it did have a hardware interrupt.

If you are planning to write a device-driver, you will need to know an awful lot about low-level kernel details, programming languages, and time-critical scheduling. Even then, the likelihood that a Thunderbolt interrupt will work just like an old-style serial-port interrupt is virtually nil.

If you already know all that for the Mac OS X kernel, then good. I suspect, however, that you don't, otherwise it's unlikely you'd have asked about a Thunderbolt interrupt at all. I think you picked "hardware interrupt" as some kind of misguided requirement, without actually understanding everything else that servicing an interrupt entails.

And if you're planning to write a device-driver, that's not likely to be something hydrographers can answer questions about. They might be able to tell you what kind of computers they buy, but I doubt that many of them write device-drivers.

Assuming you had a clear definition of what's really required at the hardware level (and I honestly doubt that, given what you've posted so far), the most sensible thing would be to remove Thunderbolt or any other Mac-based interrupt entirely.

Instead, program an external microcontroller to collect both the GPS serial message and whatever time-critical measurement is being delivered (you haven't said what that measurement is, nor how it's provided). Even something like an Arduino Uno might be able to do that, without a huge amount of programming. If it's really time-critical into the microseconds range, then you'll end up using something like a timer input-capture and possibly writing code in C rather than Arduino's unique brand of C++. The results collected by the microcontroller could then be sent to the Mac (or any other computer) over USB or any other relevant interface, without the need for time-critical drivers in the host computer.

FWIW, I'm currently working on a hardware project using an Arduino Mega for prototyping, that involves precision timing, microSD storage, and wifi communication, so I'm not just talking hypotheticals here.

EDIT
It's quite possible that your only choice is to buy a computer with a classical serial port that uses hardware interrupts. The software that runs on the computer may require those components, and there is no alternative.

Since you haven't said anything about the software, that's just a guess, but it wouldn't be the first time that some task-specific software needed specific PC hardware in order to run.

If the software does need a serial port with classical hardware interrupt, then you and your fellow hydrographers won't be able to buy any of the newer Ultrabook models, either, which lack a classical serial-port. And some other sub-compacts or netbooks might also be unusable. That's just the way it goes with task-specific software sometimes.