Annotation of researchv10no/cmd/cfront/libC/task/event.c, revision 1.1

1.1     ! root        1: /*ident        "%W%" */
        !             2: /**************************************************************************
        !             3:                        Copyright (c) 1984 AT&T
        !             4:                          All Rights Reserved   
        !             5: 
        !             6:        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
        !             7:        
        !             8:        The copyright notice above does not evidence any        
        !             9:        actual or intended publication of such source code.
        !            10: 
        !            11: *****************************************************************************/
        !            12: #include <task.h>
        !            13: 
        !            14: const  NASS = NSIG;
        !            15: 
        !            16: static Interrupt_handler*      hnd[NASS];      // hnd[i] is used for signal i
        !            17: static SIG_PF  old_handlers[NASS];
        !            18: 
        !            19: Interrupt_alerter::Interrupt_alerter()
        !            20: : ("Interrupt_alerter")
        !            21: {
        !            22:        for(;;) {
        !            23:                sleep();
        !            24:                for (register Interrupt_handler** p = &hnd[0]; p < &hnd[NASS]; p++)
        !            25:                        if (*p && (*p)->got_interrupt) {
        !            26:                                (*p)->alert();
        !            27:                        }
        !            28:        }
        !            29: }
        !            30: 
        !            31: /* Note:  the type of this function must match the definition of SIG_FUNC_TYP
        !            32:    in signal.h. */
        !            33: void
        !            34: sigFunc(int sigNo)
        !            35: {
        !            36:        if ((unsigned)sigNo >= (unsigned)NASS)
        !            37:                object::task_error(E_BADSIG, (object*)0);
        !            38:        Interrupt_handler*      as = hnd[sigNo];
        !            39:        if (as == 0)
        !            40:                object::task_error(E_NO_HNDLR, (object*)0);
        !            41:        as->interrupt();
        !            42:        as->got_interrupt = 1;
        !            43:        sched::priority_sched = &interrupt_alerter;
        !            44:        signal(sigNo, sigFunc);         //reset
        !            45:                                        //MORE:  ifdef SVR3 use sigset
        !            46: }
        !            47: 
        !            48: Interrupt_handler::Interrupt_handler(int vecid)
        !            49: : id(vecid), got_interrupt(0)
        !            50: {
        !            51:        if ((unsigned)id >= (unsigned)NASS)
        !            52:                task_error(E_BADSIG, this);
        !            53:        if((old = hnd[id]) == 0)
        !            54:                old_handlers[id] = signal(id, sigFunc);
        !            55:        else
        !            56:                if (old->got_interrupt) {
        !            57:                        old->alert();
        !            58:                }
        !            59:        hnd[id] = this;
        !            60:        this_task()->keep_waiting();
        !            61: }
        !            62: 
        !            63: Interrupt_handler::~Interrupt_handler()
        !            64: {
        !            65:        this_task()->dont_wait();
        !            66:        for(register Interrupt_handler** as = &hnd[id];; as = &(*as)->old) {
        !            67:                if (*as == this) break;
        !            68:                if (*as == 0)
        !            69:                        task_error(E_LOSTHNDLR, this);
        !            70:        }
        !            71:        if ((*as = old) == 0)
        !            72:                 signal(id, old_handlers[id]);
        !            73: }
        !            74: 
        !            75: void
        !            76: Interrupt_handler::interrupt()
        !            77: {
        !            78: }
        !            79: 
        !            80: int
        !            81: Interrupt_handler::pending()
        !            82: {
        !            83:        if (!got_interrupt)
        !            84:                return 1;
        !            85:        got_interrupt = 0;
        !            86:        return 0;
        !            87: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.