Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.system > #611

Re: how to create a interrupt service function in c for real time linux operating system?

Newsgroups comp.os.linux.development.system
Date 2014-04-02 08:46 -0700
References (5 earlier) <lhe6rl$5qv$1@dont-email.me> <dcec18ea-2cb6-4d6f-b62e-9b6fcda92817@googlegroups.com> <lhg833$qu0$2@dont-email.me> <4f42d31d-290e-4a2c-a7be-bf4bb31c4845@googlegroups.com> <lhh83h$2qp$1@dont-email.me>
Message-ID <61af4a68-e281-4a22-af35-81f417b818f7@googlegroups.com> (permalink)
Subject Re: how to create a interrupt service function in c for real time linux operating system?
From Hemanth Venkatappa <hemanthvenkatappa@gmail.com>

Show all headers | View raw


On Wednesday, 2 April 2014 20:20:24 UTC+5:30, Tauno Voipio  wrote:
> On 2.4.14 15:27, Hemanth Venkatappa wrote:
> 
> > On Wednesday, 2 April 2014 07:44:03 UTC+2, Tauno Voipio  wrote:
> 
> >> On 2.4.14 08:21, Hemanth Venkatappa wrote:
> 
> >>
> 
> >>> On Tuesday, 1 April 2014 13:10:45 UTC+2, Tauno Voipio  wrote:
> 
> >>
> 
> >>>> On 1.4.14 11:56, Hemanth Venkatappa wrote:
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>> On Thursday, 27 March 2014 16:30:30 UTC+1, Tauno Voipio  wrote:
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>>> On 26.3.14 10:46, Hemanth Venkatappa wrote:
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     >
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     >
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > Where to write a interrupt handler and how to register with kernel in
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> linux?
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     >
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > Scenario : Client is sending a data and the server is receving the
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> data from
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > client via ethernet layer (udp). When the server receives a data from
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> the client on the ip layer (kernel). It interrupts the kernel and kernel
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> as to execute the data by the client, so I want to create a interrupt
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> service function to catch the interrupt from the network service card.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     >
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > I can't write kernel modules (the kernel is not open) and you have
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> real-time in
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > user-space. However I can write code using RTLinux (real time linux)
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> in kernel
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>     > space and with kernel modules.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> Please explain what you are trying to achieve by catching the network
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> interface interrupts. It is about the most silly place in the whole
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> networking stack to catch for doing something allowed and useful.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> There are different hook positions in the network protocol stack, but
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> for most of them, you need to have superuser privileges, for obvious
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> security reasons.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> Doing anything in hardware I/O, including catching interrupts, is also
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> considered such an activity that it needs superuser privileges.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> Your description on the 'openness' is contradictory - either you have
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> the necessary privileges, or you don't have them.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> Try again to describe the ultimate goal of this exercise, so we can
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> lead you to the correct direction.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> --
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>> -TV
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> (-- extra long lines truncated -TV --)
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>> how to get the interrupt time (timestamp) in kernel mode of real time linux?
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>> client- server communication - client is sender and server is receiver.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> when the server receives the data on the ethernet interface(UDP) the kernel
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>     in the server is triggered. I am using real time LINUX on the server
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> side.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> server(i.e embedded pc target) is handling interrupts to trigger the
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> embedded
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> pc target (conatining rt linux) to gain the attention to execute the newly
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> arrived data. I want to calculate the time in kernel as soon as the
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> interrupt
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> occurs and send the response back to the client.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> Could someone please help me ??
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> You still did not tell what for you are wanting the times. The response
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> gives the necessary boundary conditions for the responses.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> Also, I did not understand what computers are in your network
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> connection. Two RT Linux machines? Is either a PC?
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> It seems to me that you have already fixed yourself to the idea of
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> timing the network interface interrupts. Do you have access to the
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> network drivers and their source code? Do you have the skills needed
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> to modify and compile a kernel driver?
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> If you want to measure the server latency from a request packet to
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> the corresponding response packet, IMHO, the simplest method is
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> to tap the network connection and grab the interesting traffic
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> with Wireshark. It will give the timing without any extra programming.
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> --
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>>
> 
> >>
> 
> >>>> -TV
> 
> >>
> 
> >>>
> 
> >>
> 
> >>> I am calculating the timestamp i.e time when the interrupt occurs and when it starts scheduling. The client is RTPROPC and server is real time linux.
> 
> >>
> 
> >>>
> 
> >>
> 
> >>
> 
> >>
> 
> >> OK. Let's continue:
> 
> >>
> 
> >>
> 
> >>
> 
> >> Why are you calculating the timestamp?
> 
> >>
> 
> >> What are you intending to use it for?
> 
> >>
> 
> >>
> 
> >>
> 
> >> --
> 
> >>
> 
> >>
> 
> >>
> 
> >> -TV
> 
> >
> 
> > I am calculating the time at which the data arrived from the client on the ethernet
> 
> layer and the time at which the kernel starts executing. So that I can 
> 
> analyse the latency
> 
> for the operating system
> 
> 
> 
> 
> 
> Please understand that the network interface interrupt service *is* part
> 
> of kernel code, so your timestamp gives only the moment the interrupt
> 
> is seen.
> 
> 
> 
> I have probed for kernel interrupt latencies with an oscilloscope on the
> 
> peripheral device interrupt line. The width of the request pulse gives
> 
> the time it takes for the interrupt to be reacted upon.
> 
> 
> 
> If you think measuring the time from the interrupt service to the
> 
> first instruction of the network protocol stack code in kernel,
> 
> the result is of little use, anyway.
> 
> 
> 
> If you think of measuring the time from the network interrupt to the
> 
> user-land code getting the UDP datagram, it would be useful, but the
> 
> results can be wildly varying, dependent upon what else is going on
> 
> in the system.
> 
> 
> 
> There are methods for timestamping, see sources of NTP daemon.
> 
> 
> 
> -- 
> 
> 
> 
> -TV

I cant code for rt linux interrupt service routine because the operating system services will be executed in the kernel mode. So I have to debug the kernel using ftrace (I think so).

Back to comp.os.linux.development.system | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-03-26 01:46 -0700
  Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-03-26 15:24 +0200
    Re: how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-03-27 00:25 -0700
      Re: how to create a interrupt service function in c for real time linux operating system? Joe Beanfish <joebeanfish@nospam.duh> - 2014-03-27 13:14 +0000
      Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-03-27 17:30 +0200
        Re: how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-04-01 01:56 -0700
          Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-04-01 14:10 +0300
            Re: how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-04-01 22:21 -0700
              Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-04-02 08:44 +0300
                Re: how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-04-02 05:27 -0700
                Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-04-02 17:50 +0300
                Re: how to create a interrupt service function in c for real time linux operating system? Hemanth Venkatappa <hemanthvenkatappa@gmail.com> - 2014-04-02 08:46 -0700
                Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-04-02 21:49 +0300
                Re: how to create a interrupt service function in c for real time linux operating system? Richard Kettlewell <rjk@greenend.org.uk> - 2014-04-02 23:13 +0100
                Re: how to create a interrupt service function in c for real time linux operating system? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2014-04-03 08:59 +0300

csiph-web