External Memory Trace PIN Tool - intel-pin

I tried using PIN tool to capture the memory trace. But, the PIN website says the addresses include all memory reads and writes.
I would like to capture the external memory addresses generated by a program. These addresses are the ones which are generated after cache accesses and hence correspond to physical address in DRAM.
Can you please let me know if I can capture the external memory address trace? I wanted to know if this is already available and if so, please point me to the source.
I saw the question: Getting physical address in pin tool
It says about conversion from virtual to physical. But, I want to get the trace of addresses after cache is accessed.

Short answer is no. Just like any other piece of software, Pin can't tell whether the load/store instruction hit/missed in the cache or not.
The best you can do with Pin I think is to write a cache simulator (you can take a look at the one which comes with Pin - pin-x.y/source/tools/SimpleExamples/dcache.cpp) and record the accesses (i.e., addresses) which missed in the simulated cache. This won't be accurate for many reasons but it can be useful depending on your needs.
This question and answer discuss a similar point by the way.

Related

Is it possible to verify the received slave data in i2C protocol

I recently came across one question related to the I2C protocol,
usually we read the data from the I2C slave devices and use it for the further calculations on the master side,
but can I be sure if the data I got is the data I wanted or is that corrupted while transmitting to the bus?
is there any possibilities to do so in I2C protocol?
In many cases, no, you can't be certain from software. You have to verify the design by hardware (with an oscilloscope) and then make sure nothing changes.
However, some slave devices provide checksums or check bits on certain transactions that can be used to detect some faults.
Reading a known value from the ID register at startup is usually good enough for most applications.
Remember that if your data is getting corrupted then maybe your addresses are too, and that will cause ACKs to not be returned when you expect them.
Many things you can do from software will not detect an error instantly though, so you need to think about how important or harmful it could be if an incorrect value is used. There are various standards that help you plan for this, such as ISO 14971 "Application of risk management to medical devices".

Is a tcp port number somehow used as a pointer to memory?

I'm trying to understand ports on a low-level. I've been moved from SF and google did no good so hopefully this will be on-topic as low-level programming (it should be).
Ports are just numbers used to access a program/service. The only way I can see this implemented is by using the port number to send data to an address space (stack?) allocated for specific use by the program/service. Hence the program/service is looking, a.k.a. "listening", for specific data (protocol-specific) in that address space or "port." Is this anywhere close to being correct?
Hence the program/service is looking, a.k.a. "listening", for specific data (protocol-specific) in that address space or "port."
No, not really. The most important piece of the puzzle here is the kernel. When a program "opens a listener on a port", in reality that's a call into the kernel to say "I want to listen on this port". The kernel is going to remember that, probably in some kind of lookup table.
When a packet arrives, it's the kernel's job to handle the receipt of that packet, parse it, and route the payload to the correct place. At this point, the kernel is going to lookup which program is registered for that port, and tell it about the new data that has arrived. That's a complex process, because the program might be asleep (blocked waiting for new data) or it might be running some other code, in which case the new data needs to be queued.
The main point to take away is that your userspace program isn't "listening". It's up to the kernel to decide when it runs and whether to wake it. The port number in your original question becomes a lookup into a table that the kernel keeps.
You can think of it like an array index. That's really as far as you need to go into the details.

GSM network network overhead issue

I am try to learn GSM network issues. I would like to know more about in detail "Trade-off between network overhead and call setup time". why network overhead will occurs and how it reflect on call setup time
Seems an odd question (I am guessing it from some course etc?).
All networks will have an overhead to set up a call, so maybe this is referring to the extra work required to 'find' the terminating mobile device.
This requires a query to the GSM 'database' associated with the terminating subscriber, the HLR (Home Loctaion Register).
Call setup is generally prioritised over other traffic, including paging in the terminating cell to tell the terminating device there is a call - other than that there is not a lot of specific overhead. IN high congestion situations the terminating cell may not be able to page the device which can mean the call cannot be set up - maybe this is what the question was referring to.

Getting current transferred MPI network communication volume

I have a question related to MPI.
In order to keep track of the communication volume used by my implementation, I would like to get the currently-transferred data amount since the mpi-process' start until the current measure-point.
I checked the specification as well as the mpi.h header file of mpich and did not find a matching function to call or variable that keeps track of the network transfer costs. It would, of course, be possible to implement a small traffic registry or define a macro for tracking communication sizes, but maybe it can be read out from somewhere.
Do you know a method to gain the current transfer size, maybe it is also possible to get this number using a system call to get the network traffic size of the process?
Is it maybe possible to access the proc information of the current process, maybe the /proc/net is maintained per process as well, such as /proc/self/net?
Thank you in advance,
Martin

Serial Comms dies in WinXP

A bit of history: We have an application, which was originally written many years ago (1998 is the first date in PVCS but the app is about 5 years older than that as it originally was a DOS program). This application communicates with a piece of hardware via serial. When we got to Windows XP we started receiving reports of the app dying after a short time of running. It seems that the serial comms just 'died' and the app was left in a stuck state. The only way to recover from this situation was to restart the application.
The only information I can find regarding this problem was apparently the Windows Message system would miss that information was received, the buffer would fill and the system would get stuck. This snippet of information was left in a old word document, but there's no evidence to back this up. It also mentions that this is only prevalent at high baud rates (115200+).
The solution was to provide customers with USB->Serial converters along with the hardware.
Today: We are working on a new version of the hardware that will run across a network as well as serial ports. So to allow me to work on the network code, minus the actual hardware we are using a VSCOM NetCom113 device. It also installs a virtual comm port on the users (ie: mine) machine.
Now I have got the network code integrated with the app, it appears that the NetCom device exhibits the same behaviour as a physical commport. This is undesirable as I need the app to run longer than ~30 seconds.
Google turns up zero problems that we experience.
I was wondering:
Has anyone experienced this before? If so what did you do to fix/workaround the problem?
Does anyone have any suggestions as to whether the original author of the document is correct and what I can do to test the theory?
Unfortunately I can't post code as the serial code is tightly couple with the rest of the system, though if you have questions regarding it I can answer questions about it.
Updates:
The code is written using Win32 Comm routines - so I am using CreateFile, ReadFile. There's also judicious calls to GetOverlappedResult.
It's not hanging per se, it's just that the comms stops. You can access the menus, click the buttons, but nothing can interact with the connected hardware. Using realterm you can see that no data is coming in or going out.
I think the reference to the windows message is that the problem is internal to windows. Data has arrived but the kernal has missed it and thus not told the rest of the system about it.
Flow control is not used.
Writing a 'simple' test is difficult due the the fact that the code is tightly coupled and the underlying protocol is quite complex and would require a lot of work.
Are you using DOS-style serial code, or the Win32 CreateFile approach?
If the former, be very suspicious: if at all possible I'd convert to the latter.
If the latter, do you know on what kind of system call it's hanging? Are you in a blocking read call? or an overlapped I/O call? or waiting on an event? (I'm not sure I have enough experience to help, but those are the kinds of questions that come to mind)
You might also check into the queue size, which you can set with the SetupComm function.
I don't buy the "Windows Message system" stuff -- it sounds fishy; you can write good Win32 serial i/o code that never uses Windows messages.
edit: does your Overlapped I/O use events? I seem to remember something about auto-reset events occasionally missing their trigger... check your overlapped I/O calls very carefully to see whether you're handling the possible outcomes properly. Perhaps there's a way to make your code more robust by automatically cancelling the overlapped i/o and restarting another read. (I assume the problem is in the read half, not the write half?)
edit 2: A suggestion: assuming the win32 side has missed a byte or packet, and your devices are in deadlock because they're both expecting each other to respond to something, can you tweak the other side of the serial I/O to regularly send some type of "ping" packet with an incrementing counter? (and log the ping packets on the PC side; that way you can see whether you've missed any)
Are you sure you have your flow control set up correctly? DTR, RTS, etc...
-Adam
i have written apps that use usb / bluetooth serial ports and have never had an issue. with bluetooth i have seen bit rates (sustained) of 800,000 bps for long periods of time. most people don't properly implement the port.
My serial port
Not sure if this is a possibility for you, but if you could re-write the code using C#.NET you'd have access to the SerialPort class there. It might remedy your problem. I know a lot of legacy code based around the Win32 API for hardware I/O ports tended to fail in XP due to timing (had a small bit of experience with MIDI).
In addition, I don't know if you can use the Win32 method of Serial Port access in Vista, so that might shut out future MS OSes from being able to use your code.

Resources