what happens internally

Discussion in 'Operating System' started by anchitjindal07, Aug 9, 2009.

  1. anchitjindal07

    anchitjindal07 New Member

    Joined:
    Jul 13, 2009
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Friends please tell me what happens internally when we press any key on keyboard
    i know that it saves the value of certai registers and taKES ON INTERRUPT handler. upto this point its ok. what happen after that???????
    What is interrupt handler instructed to do???????????

    Thanks
     
  2. Seema786

    Seema786 New Member

    Joined:
    Jul 29, 2009
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    IT Professional
    Location:
    Banglore
    anyone know what he/she is telling ?
     
  3. anchitjindal07

    anchitjindal07 New Member

    Joined:
    Jul 13, 2009
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    yaar i am asking u how the operatring system knows which key has been pressed and what to do when a particular key is pressed
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Which OS?
     
  5. anchitjindal07

    anchitjindal07 New Member

    Joined:
    Jul 13, 2009
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Any oerating system. Ok take your own example (of OS) and please explain
     
  6. indiansword

    indiansword Security Expert

    Joined:
    Oct 19, 2008
    Messages:
    491
    Likes Received:
    37
    Trophy Points:
    0
    Occupation:
    Operation Planner for 3 Australia
    Home Page:
    http://www.Secworm.net
    Input > Process > Output. THere is a RUBBER NOTCH beneath ur keyboard key. When u push the key the NOTCH is pushed and the circuit on the keyboard is completed, which send a msg to CPU [PROCESSOR] and the key is recorded, and output on application along with monitor :) .
     
  7. anchitjindal07

    anchitjindal07 New Member

    Joined:
    Jul 13, 2009
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Thankyou friend for ur reply but I am asking in terms of interrupt. Would you please explain
     
  8. _eb75_

    _eb75_ New Member

    Joined:
    Jun 18, 2012
    Messages:
    16
    Likes Received:
    6
    Trophy Points:
    0
    Location:
    www.isosika.net
    I like questions with the word internally.
    To my mind it would be good to give an answer with a full exact code, to be at a concrete level. Unfortunately this is impossible, because we have too much code. Is it really? This question is easy because it don't specify any kernel by name. So, I can use my own! I did write it 1994 when Intel 386, protected mode, was new. It is small and simple enough (some 1000-1500 c-code whole thing). I tested it also taking a connection to a server by the serial line modem (telnet port at server).

    Code:
    char  KBDSub() 
    { static short code;
      static short xl, xh;
      static char scan[]={  /* Scan code conversion table for most usual codes */
      0,033,'1','2','3','4','5','6','7','8','9','0','+','x','\b','\t',
      'q','w','e','r','t','y','u','i','o','p','?',012,015,015,
      'a','s','d','f','g','h','j','k','l','&','?',0,
      '\\',',','z','x','c','v','b','n','m',',','.','-','/',0,' ',' ',' ',' '};
    
       code = inportb(0x060)   ;
       xh = xl = inportb(0x061);    /* Read scan code*/
       xl = xl | 0x080         ;
        outportb( 0x61 , xl)    ;
       outportb( 0x061, xh)    ;
       if(code >=0 && code <=0x040 ) return(scan[ code]);
       else return( 0);
    }
    
    void  KBDIntHandler() 
    {       outportb(PIC1_CMND,PIC_EOI);
                  Send(0,KBD_BOX,KBDSub()); // send message to mailbox- hopefully keyboard task is waiting!
    }
    
    **********************************************************

    Outside the question presented:

    Yes, saving on entry must be done:

    Code:
    #define Save()      asm volatile ("pusha"); 
    #define Restore() asm ("popa;leave;iret;"); 
    
    Where this saving/restoring is?

    Interrupt call gate.

    Code:
    void InterruptHandler() 
    {
      short store;
     Save();
     enter_int_gate(store);
          KBDIntHandler();
     leave_int_gate(store);
     Restore();
    }
    Code:
    (#define  leave_int_gate(STORE)  asm("movw %0,%%bx;movw %%bx,%%ds;"\
                                         :\
                        :"m"(STORE));)

    A KBD task:


    Code:
    void main(void) {
     while(TRUE) {
    ................
      kbd_char = receive(KBD_BOX,TIMEOUT);
     ................
     }
    }

    and so on................................I used mainly c and some inline assembly, only floppy disk (see history of computers) boot sector was written using assembly...........
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice