Thread: kernel Interrupt

  1. #1
    Registered User
    Join Date
    Feb 2009
    Location
    India, Gujarat
    Posts
    22

    kernel Interrupt

    If my network interface was down then kernel give me interrupt or any signal?

    if my interface was down then my software must know, I don't want poll any fd.
    the kernel has to give signal or interrupt to my software.

    Is this Possible? how?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What do you mean by "down"? "ifconfig eth0 down" or "someone pulled the wire out"?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Location
    India, Gujarat
    Posts
    22
    In both case.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It may be that the hardware gives an interrupt for the "wire got disconnected", it almost certainly doesn't when you tell it "shut yourself down" [ok, so maybe some of that requires sending commands to the network device and those commands return an interrupt to say "Ok, I've done that now, anything else you want me to do?"]

    Also, if you want to check the connectivity between your machine and the rest of the world, you would have to do polling [by sending a ping to some machine that you know should be reachable] - just because YOUR machine has the wire connected to a HUB doesn't meant that the hub is connected to anything.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Feb 2009
    Location
    India, Gujarat
    Posts
    22
    is there some type of architecture or mechanism which told me about this type of event?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by vipul_vgp View Post
    is there some type of architecture or mechanism which told me about this type of event?
    I'm not sure. There is a message in the system event log, so you may be able to trace that down.

    But I still ask: What is the purpose of ONLY detecting that the device is down, when that is pointless, and what really needs to be known is that the system is connected to the network properly or not - which involves sending a ping or some such to another machine!

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Feb 2009
    Location
    India, Gujarat
    Posts
    22
    cause my s/w is one type of monitor which monitor all the devices of system and report the administrator for devise failure. and my s/w must be lightweight so that's why instate of polling interrupt is best.

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    But if you poll once a second, I can assure you that anything but a very low-end machine (something less than a 33MHz 486) there would be measurable difference in performance - and it would tell you MORE about the system.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Mar 2009
    Location
    Cape Town
    Posts
    6
    I agree with Mats, you can easily write a task that polls your network card/switch or any network interface and then log/report if there is any detected fault. I have done it on a point to point radio that I developed (the task runs once a second and checks a five port switch status). The only problem is if your network interface is down and you need to send an IP message to the administrator....

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by nsayag View Post
    The only problem is if your network interface is down and you need to send an IP message to the administrator....
    Yeah, but that is a problem whatever the REASON for the network being down is, and also not solvable by any of the discussions here.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Just as an addendum to this, one of my systems (the one I use the most, unfortunately) has some kind of problem whereby I actually have to leave ping running in the background all the time (at it's default rate, maybe once or twice a second) in order to keep my net connection up properly, and this does not noticably hamperer either the connection speed or place any "strain" on the processor/resources.

    One of these days I should track this down, since the other installation on the exact same computer with the same netlink does not have that problem...but anyway, they are both linux and matsp is correct, there is no point in just polling the device because the network could be down or unreachable and such a check will not be able to tell, since polling the network device does not mean polling the network.

    Use ping.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer within a Struct
    By Bladactania in forum C Programming
    Replies: 11
    Last Post: 04-03-2009, 10:20 PM
  2. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM
  3. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM
  4. interrupt handler functions in Visual C++ 6.0
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 01-07-2002, 07:06 PM
  5. Sound card interrupt problems
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-05-2001, 04:38 AM