/*** Add a server when their shift starts. ***/ void ADDECON() { int _edge_condition[2]; /* state changes */ ECONGS=ECONGS+1; SERVER[0]=SERVER[0]+1; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( ECONGS<ECONEX ); _edge_condition[1] = ( QUEUE[0]>0 ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ADDECON_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = STEE_event; event_priority = 5; schedule_event(); } }
/*** A first class server chooses to help a first class or economy passengers. ***/ void ASSIGN() { int _edge_condition[2]; /* state changes */ DECSERV=0; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( QUEUE[0]>0&&QUEUE[1]==0&&SERVER[0]==0&&SERVER[1]>0 ); _edge_condition[1] = ( QUEUE[1]>0 ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = STFCE_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = STFCFC_event; event_priority = 5; schedule_event(); } }
static void create_burst(xProcess_PCB_ptr process) { time_t burst_length; time_t io_service_time; char buffer[BUFFER_SIZE]; /* Determine the length of the CPU burst */ burst_length = gaussian_random(CPU_BURST_MEDIAN, CPU_BURST_SIGMA); /* * Determine the manner in which the quantum will end. The idle * process always runs to the end of its quantum */ if (xSimulator_time() + burst_length > timer_time) { /* CPU Burst */ /* Determine if the process will end on this CPU burst */ if (0 == (rand() % END_PROCESS_PROBABILITY)) { burst_length = rand() % (timer_time - xSimulator_time()); process_end_time = xSimulator_time() + burst_length; process_end_event = schedule_event(process_end_time, xSystem_process_end, NULL); } else { /* Just allow the timer to handle everything */ } } else { /* The slice ends with blocking I/O */ io_start_time = xSimulator_time() + burst_length; io_service_time = gaussian_random(IO_BURST_MEDIAN, IO_BURST_SIGMA); io_end_time = io_start_time + io_service_time; io_start_event = schedule_event(io_start_time, xSystem_io_start, NULL); io_end_event = schedule_event(io_end_time, xSystem_io_end, process); snprintf(buffer, BUFFER_SIZE, "Scheduled I/O burst to end at %08ld.", io_end_time); print(process, buffer); } }
static inline void modem_fill(struct BCState *bcs) { if (bcs->tx_skb) { if (bcs->tx_skb->len) { write_modem(bcs); return; } else { if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) && (PACKET_NOACK != bcs->tx_skb->pkt_type)) { u_long flags; spin_lock_irqsave(&bcs->aclock, flags); bcs->ackcnt += bcs->hw.hscx.count; spin_unlock_irqrestore(&bcs->aclock, flags); schedule_event(bcs, B_ACKPENDING); } dev_kfree_skb_any(bcs->tx_skb); bcs->tx_skb = NULL; } } if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) { bcs->hw.hscx.count = 0; test_and_set_bit(BC_FLG_BUSY, &bcs->Flag); write_modem(bcs); } else { test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); schedule_event(bcs, B_XMTBUFREADY); } }
/*** Add a first class server when their shift starts ***/ void ADDFC() { int _edge_condition[2]; /* state changes */ FCGS=FCGS+1; SERVER[1]=SERVER[1]+1; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); _edge_condition[1] = ( FCGS<FCEX ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ASSIGN_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ADDFC_event; event_priority = 5; schedule_event(); } }
/*** ARRIVAL OF ANY CUSTOMER, where M is uniform rv[01] ***/ void CUSTM() { int _edge_condition[3]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; /* state changes */ C[J]=C[J]+1; M=RND; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); _edge_condition[1] = ( M>R&&S[J]>0 ); _edge_condition[2] = ( M<=R ); /* schedule future events */ if (_edge_condition[0]) /*** SCHEDULE THE NEXT ARRIVAL ( arrive according to some distribution specified by the customer type) ***/ { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; for ( t_index=4; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 3+ARRMM[J][1]*BET(2,2); event_type = CUSTM_event; event_priority = 6; schedule_event(); } if (_edge_condition[1]) /*** THE CUSTOMER BELONGS TO WALKIN ***/ { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; transfer[4] = M>R; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = WALKIN_event; event_priority = 5; schedule_event(); } if (_edge_condition[2]) /*** Delay needs to be determined by something that depends on the customer type. CAR IS SUPPOSED TO BE RESERVED ***/ { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; transfer[4] = M>R; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 1+RES*BET(1.2,1.2)-1; event_type = RESERV_event; event_priority = 3; schedule_event(); } }
/*** Generate input ( 4 types of cars) ***/ void INPUT() { int _edge_condition[3]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; K = (long) transfer[4]; /* state changes */ ENT[1]=J; ENT[0]=K; RNK[J]=0; K=K+0*PUT(INC,J); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( J<=4&&K<S[J]-1 ); _edge_condition[1] = ( J<4&&K>=S[J]-1 ); _edge_condition[2] = ( K>=S[J]-1 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; transfer[4] = K+1; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = INPUT_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J+1; transfer[4] = 0; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = INPUT_event; event_priority = 5; schedule_event(); } if (_edge_condition[2]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; for ( t_index=4; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = costs_event; event_priority = 5; schedule_event(); } }
/* Switches between visualization modes */ void fsv_set_mode( FsvMode mode ) { boolean first_init = FALSE; switch (globals.fsv_mode) { case FSV_SPLASH: /* Queue desired mode */ initial_fsv_mode = mode; return; case FSV_NONE: /* Filesystem's first appearance */ first_init = TRUE; break; default: /* Set initial mode for next time */ initial_fsv_mode = mode; break; } /* Generate appropriate visualization geometry */ geometry_init( mode ); /* Set up initial camera state */ camera_init( mode, first_init ); globals.fsv_mode = mode; /* Ensure that About presentation is not up */ about( ABOUT_END ); /* Render one frame before performing the initial camera pan. * There are two separate reasons for doing this: */ if (first_init) { /* 1. Practical limitations make the first frame take an * unusually long time to render, so this avoids a really * unpleasant camera jump */ schedule_event( initial_camera_pan, "new_fs", 1 ); } else { /* 2. In order to do a camera pan, the geometry needs to * be defined. We just called geometry_init( ), but if the * camera's going to a non-root node, it may very well not * have been laid out yet (but it will be when drawn) */ schedule_event( initial_camera_pan, "", 1 ); } }
/*** Set the number of expected economy servers in the system at the beginning of a shift. ***/ void SETSRVR() { int _edge_condition[3]; /* state changes */ ECONEX=ECONES[TIMEIDX]; FCEX=FCES[TIMEIDX]; TIMEIDX=TIMEIDX+1; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( TIMEIDX<6 ); _edge_condition[1] = ( ECONGS<ECONEX ); _edge_condition[2] = ( FCGS<FCEX ); /* schedule future events */ if (_edge_condition[0]) /*** Every four hours, update the number of servers in the system. ***/ { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 240; event_type = SETSRVR_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) /*** Add extra servers to economy staff if needed ***/ { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ADDECON_event; event_priority = 5; schedule_event(); } if (_edge_condition[2]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ADDFC_event; event_priority = 5; schedule_event(); } }
static int nodemenu_select(ClientData data, Tcl_Interp *interp, int argc, char *argv[]) { extern void unschedule_node(int node); int n, s; if(vflag) { for(n=0 ; n<argc-1 ; ++n) fprintf(stderr,"%s ", argv[n]); fprintf(stderr,"%s\n", argv[argc-1]); } if(argc != 3) { interp->result = "wrong # args"; return TCL_ERROR; } n = atoi(argv[1]); s = atoi(argv[2]); if(n < 0 || n >= _NNODES || s < 0 || s >= N_NODEMENU_STRINGS) { interp->result = "invalid node or menu arg"; return TCL_ERROR; } switch (s) { case RE : NP[n].runstate = STATE_REBOOTING; schedule_event(EV_REBOOT, n, int64_ONE, NULLTIMER, NP[n].data[(int)EV_REBOOT]); break; case CR : NP[n].runstate = STATE_CRASHED; unschedule_node(n); break; case SR : NP[n].runstate = STATE_AUTOREBOOT; schedule_event(EV_REBOOT, n, int64_ONE, NULLTIMER, NP[n].data[(int)EV_REBOOT]); break; case P1 : case P6 : NP[n].runstate = STATE_PAUSED; int64_I2L(NP[n].will_resume, (s == P1 ? 10000000 : 60000000)); schedule_event(EV_REBOOT, n, NP[n].will_resume, NULLTIMER, NP[n].data[(int)EV_REBOOT]); int64_ADD(NP[n].will_resume, TIMENOW_in_USEC,NP[n].will_resume); break; } draw_node_icon(FALSE,n); if(dflag) fprintf(stderr,"%s.menu -> %s\n", NP[n].nodename, menu_strings[s]); return TCL_OK; }
/*** Economy servers start service for economy passengers ***/ void STEE() { int _edge_condition[2]; /* state changes */ QUEUE[0]=QUEUE[0]-GET(FST,0); SERVER[0]=SERVER[0]-1; DEPTIME=ENT[4]; DECSERV=0; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = DEPTIME; for ( t_index=4; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + ECONBASE+ECONBAG*RND*ENT[2]+ECONTIX*RND*ENT[3]; event_type = FINEE_event; event_priority = 5; schedule_event(); } }
/*** Economy servers finish service for economy passengers ***/ void FINEE() { int _edge_condition[2]; /* Attribute Value(s) Passed to this Event */ DEPTIME = (long) transfer[3]; /* state changes */ SERVER[0]=SERVER[0]+(ECONGS<=ECONEX); MISSFL=MISSFL+(CLK>(DEPTIME-30)); DECSERV=(ECONGS>ECONEX); ECONGS=ECONGS-(ECONGS>ECONEX); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( QUEUE[0]>0&&DECSERV==0 ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = STEE_event; event_priority = 5; schedule_event(); } }
static int serial_store(unsigned cpunum, void *d, uint32_t offset, uint32_t val) { struct ser_data *sd = d; (void)cpunum; switch (offset) { case SERREG_CHAR: if (!sd->sd_wbusy) { sd->sd_wbusy = 1; g_stats.s_wchars++; console_putc(val); schedule_event(SERIAL_NSECS, sd, 0, serial_writedone, "serial write"); } return 0; case SERREG_RIRQ: storeirq(&sd->sd_rirq, val); setirq(sd); return 0; case SERREG_WIRQ: storeirq(&sd->sd_wirq, val); setirq(sd); return 0; } return -1; }
/*** First class servers finish service for economy passengers ***/ void FINFCFC() { int _edge_condition[1]; /* Attribute Value(s) Passed to this Event */ DEPTIME = (long) transfer[3]; /* state changes */ SERVER[1]=SERVER[1]+(FCGS<=FCEX); MISSFLFC=MISSFLFC+(CLK>(DEPTIME-30)); DECSERV=(FCGS>FCEX); FCGS=FCGS-(FCGS>FCEX); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( DECSERV==0 ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ASSIGN_event; event_priority = 5; schedule_event(); } }
static void setctl(struct net_data *nd, u_int32_t val) { if ((val & NDC_ZERO) != 0) { hang("Illegal network control register write"); } else { if (val & NDC_START) { if (nd->nd_control & NDC_START) { hang("Network packet send started while " "send already in progress"); } else { schedule_event(NETWORK_LATENCY, nd, 0, triggersend, "packet send"); } } else if (nd->nd_control & NDC_START) { /* cannot turn it off explicitly */ val |= NDC_START; } nd->nd_control = val; } }
/*** RESERVATIONS MADE HERE ***/ void RSVP() { int _edge_condition[1]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; I = (long) transfer[4]; /* state changes */ S[J]=S[J]-(GET(FST,J)); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = ENT[0]; transfer[4] = ENT[1]; transfer[5] = ENT[2]; transfer[6] = ENT[3]; transfer[7] = ENT[4]; transfer[8] = ENT[5]; transfer[9] = ENT[6]; for ( t_index=10; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 1; event_type = RENT_event; event_priority = 4; schedule_event(); } }
/*** ***/ void costs() { int _edge_condition[1]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; /* state changes */ INICOST[J]=PRICEINS[J]*S[J]; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; for ( t_index=4; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = CUSTM_event; event_priority = 5; schedule_event(); } }
/*** INITIALIZATION OF THE QUEUE AND THE SERVER ***/ void RUN() { int _edge_condition[1]; /* Attribute Value(s) Passed to this Event */ /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); /* schedule future events */ if (_edge_condition[0]) /*** INITIATE THE FIRST JOB ARRIVAL ***/ { /*** attribute value(s) to be transferred to event ***/ transfer[3] = 1; transfer[4] = 0; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = INPUT_event; event_priority = 5; schedule_event(); } }
void recv_Bchannel(struct bchannel *bch, unsigned int id, bool force) { struct mISDNhead *hh; /* if allocation did fail upper functions still may call us */ if (unlikely(!bch->rx_skb)) return; if (unlikely(!bch->rx_skb->len)) { /* we have no data to send - this may happen after recovery * from overflow or too small allocation. * We need to free the buffer here */ dev_kfree_skb(bch->rx_skb); bch->rx_skb = NULL; } else { if (test_bit(FLG_TRANSPARENT, &bch->Flags) && (bch->rx_skb->len < bch->minlen) && !force) return; hh = mISDN_HEAD_P(bch->rx_skb); hh->prim = PH_DATA_IND; hh->id = id; if (bch->rcount >= 64) { printk(KERN_WARNING "B%d receive queue overflow - flushing!\n", bch->nr); skb_queue_purge(&bch->rqueue); } bch->rcount++; skb_queue_tail(&bch->rqueue, bch->rx_skb); bch->rx_skb = NULL; schedule_event(bch, FLG_RECVQUEUE); } }
static void W6692_new_ph(struct w6692_hw *card) { if (card->state == W_L1CMD_RST) ph_command(card, W_L1CMD_DRC); schedule_event(&card->dch, FLG_PHCHANGE); }
/*** Initialize the Run ***/ void RUN() { int _edge_condition[2]; /* Attribute Value(s) Passed to this Event */ /* state changes */ ECONBASE=1; ECONBAG=3; ECONTIX=2; FCBASE=1; FCBAG=2; FCTIX=1; SERVER[0]=ECONES[0]; SERVER[1]=FCES[0]; ECONGS=ECONES[0]; FCGS=FCES[0]; TIMEIDX=0; PASTOTAL=DISK(DATA.DAT,0); PASCOUNT=0; /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); _edge_condition[1] = ( 1==1 ); /* schedule future events */ if (_edge_condition[0]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = ARRIVE_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = SETSRVR_event; event_priority = 5; schedule_event(); } }
/*** A CUSTOMER THAT IS WALKIN ***/ void WALKIN() { int _edge_condition[2]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; I = (long) transfer[4]; /* state changes */ L1[J]=L1[J]+(S[J]<=0); S[J]=S[J]-(GET(FST,J)); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( 1==1 ); _edge_condition[1] = ( S[J]<=0 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = ENT[0]; transfer[4] = ENT[1]; transfer[5] = ENT[2]; transfer[6] = ENT[3]; transfer[7] = ENT[4]; transfer[8] = ENT[5]; transfer[9] = ENT[6]; for ( t_index=10; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = RENT_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) /*** If there are no types of cars available we lose the customer ***/ { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = LVE_event; event_priority = 5; schedule_event(); } }
static void isac_ph_state_change(struct isac_hw *isac) { switch (isac->state) { case (ISAC_IND_RS): case (ISAC_IND_EI): ph_command(isac, ISAC_CMD_DUI); } schedule_event(&isac->dch, FLG_PHCHANGE); }
// event handler static void event_handle(Event* e) { Component* component = component_list[e->component_id]; switch(e->event_type) { case ARRIVAL: { Customer *c; double next_time = generate_customer(C2G(component),e->timestamp,&c); Event* departure_event = event_router(c,C2G(component)->D); if(departure_event) { schedule_event(departure_event); } Event *arrival_event = e;//reuse e->timestamp = next_time; schedule_event(arrival_event); }break; case DEPARTURE: { Queue* queue = C2Q(component); Customer *c = out_queue(queue); c->time_serve = e->serve_time; double next_time = simulation_serve(c,queue); Event* departure_event = event_router(c,queue->D); if(departure_event) { schedule_event(departure_event); } if(!is_queue_empty(queue)) { Event* next_departure_event = e; next_departure_event->timestamp = next_time; next_departure_event->serve_time = next_time - now_time; schedule_event(next_departure_event); }else free(e); }break; default: printf("event type error\n"); exit(-1); } }
/* Create all data structures needed by the simulator */ void xSystem_initialise(time_t time) { xSimulator_print("Simulated system initialised."); xProcess_initialise(); xScheduler_initialise((CPU_BURST_MEDIAN * 80) / 100); /* Start the simulation with the most benign call possible */ schedule_event(10, xSystem_timer_event, NULL); }
static void create_process(void) { xProcess_PCB_ptr process; time_t time; process = xProcess_create(rand() % (PRIORITY_MAXIMUM + 1)); time = xSimulator_time() + gaussian_random(CPU_BURST_MEDIAN, CPU_BURST_SIGMA); schedule_event(time, xSystem_process_start, process); }
static void serial_pushinput(void *d, uint32_t junk) { struct ser_data *sd = d; uint32_t ch; (void)junk; if (sd->sd_inbufhead==sd->sd_inbuftail) { sd->sd_rbusy = 0; } else if (!sd->sd_didread && sd->sd_rirq.si_ready != 0) { sd->sd_droppedreads++; if (sd->sd_droppedreads == 1000000000 / SERIAL_NSECS) { msg("Kernel not responding; console input suspended"); } schedule_event(SERIAL_NSECS, sd, 0, serial_pushinput, "serial read"); } else { ch = (uint32_t)(unsigned char)sd->sd_inbuf[sd->sd_inbufhead]; sd->sd_inbufhead = (sd->sd_inbufhead+1)%INBUF_SIZE; if (sd->sd_droppedreads > 0) { msg("Held up to %u input characters while kernel" " unresponsive", sd->sd_droppedreads); sd->sd_droppedreads = 0; } sd->sd_readch = ch; sd->sd_didread = 0; sd->sd_rirq.si_ready = 1; setirq(sd); sd->sd_rbusy = 1; schedule_event(SERIAL_NSECS, sd, 0, serial_pushinput, "serial read"); } }
static void main_rec_2bds0(struct BCState *bcs) { struct IsdnCardState *cs = bcs->cs; int z1, z2, rcnt; u_char f1, f2, cip; int receive, count = 5; struct sk_buff *skb; Begin: count--; if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) { debugl1(cs, "rec_data %d blocked", bcs->channel); return; } SelFiFo(cs, HFCB_REC | HFCB_CHANNEL(bcs->channel)); cip = HFCB_FIFO | HFCB_F1 | HFCB_REC | HFCB_CHANNEL(bcs->channel); WaitNoBusy(cs); f1 = ReadReg(cs, HFCD_DATA, cip); cip = HFCB_FIFO | HFCB_F2 | HFCB_REC | HFCB_CHANNEL(bcs->channel); WaitNoBusy(cs); f2 = ReadReg(cs, HFCD_DATA, cip); if (f1 != f2) { if (cs->debug & L1_DEB_HSCX) debugl1(cs, "hfc rec %d f1(%d) f2(%d)", bcs->channel, f1, f2); z1 = ReadZReg(cs, HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_CHANNEL(bcs->channel)); z2 = ReadZReg(cs, HFCB_FIFO | HFCB_Z2 | HFCB_REC | HFCB_CHANNEL(bcs->channel)); rcnt = z1 - z2; if (rcnt < 0) rcnt += cs->hw.hfcD.bfifosize; rcnt++; if (cs->debug & L1_DEB_HSCX) debugl1(cs, "hfc rec %d z1(%x) z2(%x) cnt(%d)", bcs->channel, z1, z2, rcnt); if ((skb = hfc_empty_fifo(bcs, rcnt))) { skb_queue_tail(&bcs->rqueue, skb); schedule_event(bcs, B_RCVBUFREADY); } rcnt = f1 - f2; if (rcnt < 0) rcnt += 32; if (rcnt > 1) receive = 1; else receive = 0; } else receive = 0; test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); if (count && receive) goto Begin; return; }
/*** This is where reservations will be "held" At this time if there are no cars available then we lose the reservation ***/ void RESERV() { int _edge_condition[2]; /* Attribute Value(s) Passed to this Event */ J = (long) transfer[3]; I = (long) transfer[4]; /* state changes */ L2[J]=L2[J]+(S[J]<=0); /* Evaluate edge conditions now so that they will*/ /* not be changed by preemptive event execution */ _edge_condition[0] = ( S[J]>0 ); _edge_condition[1] = ( S[J]<=0 ); /* schedule future events */ if (_edge_condition[0]) { /*** attribute value(s) to be transferred to event ***/ transfer[3] = J; transfer[4] = I; for ( t_index=5; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = RSVP_event; event_priority = 5; schedule_event(); } if (_edge_condition[1]) { for ( t_index=3; t_index<maxatr; t_index++) transfer[t_index] = 0.0; event_time = current_time + 0; event_type = LVE_event; event_priority = 5; schedule_event(); } }
static void keepalive(void *data, u_int32_t junk) { struct linkheader lh; struct net_data *nd = data; int r; (void)junk; /* * Because we're using a connectionless socket, the hub won't * know we exist until we send it a packet. So let's send it a * packet. In fact, let's do this say once a second all along * in case the hub crashes and restarts. */ lh.lh_frame = htons(FRAME_MAGIC); lh.lh_from = htons(nd->nd_status & NDS_HWADDR); lh.lh_packetlen = htons(sizeof(lh)); lh.lh_to = htons(HUB_ADDR); r = sendto(nd->nd_socket, (void *)&lh, sizeof(lh), 0, (struct sockaddr *)&nd->nd_hubaddr, nd->nd_hubaddrlen); if (r<0 && (errno==ECONNREFUSED || errno==ENOENT || errno==ENOTSOCK)) { /* * No carrier. */ if (!nd->nd_lostcarrier) { msg("nic: slot %d: lost carrier", nd->nd_slot); nd->nd_lostcarrier = 1; } HWTRACE(DOTRACE_NET, "nic: slot %d: keepalive rejected: %s", nd->nd_slot, strerror(errno)); } else if (r<0) { msg("nic: slot %d: keepalive to %s failed: %s", nd->nd_slot, nd->nd_hubaddr.sun_path, strerror(errno)); HWTRACE(DOTRACE_NET, "nic: slot %d: keepalive failed", nd->nd_slot); } else { if (nd->nd_lostcarrier) { msg("nic: slot %d: carrier detected", nd->nd_slot); nd->nd_lostcarrier = 0; } HWTRACE(DOTRACE_NET, "nic: slot %d: keepalive succeeded", nd->nd_slot); } schedule_event(1000000000, nd, 0, keepalive, "net keepalive"); }