Пример #1
0
/*
 *  Tell the SCSI layer about a BUS RESET.
 */
void sym_xpt_async_bus_reset(struct sym_hcb *np)
{
	printf_notice("%s: SCSI BUS has been reset.\n", sym_name(np));
	np->s.settle_time = jiffies + sym_driver_setup.settle_delay * HZ;
	np->s.settle_time_valid = 1;
	if (sym_verbose >= 2)
		printf_info("%s: command processing suspended for %d seconds\n",
			    sym_name(np), sym_driver_setup.settle_delay);
}
Пример #2
0
static __inline__ void
display_dashline(int last_row)
{
	int		i;

	scrn_setw(last_row);
	last_row--;
    scrn_pos(last_row, 1);
    for(i=0; i<(mcos.scrn->ncols-15); i++)
    	printf_info("-");
    scrn_printf(last_row, 2, " MCOS Demo %s ", mcos_demo_version());
}
Пример #3
0
void dequeue_task(task_small_t* task) {
    lock(mutex);
    if (task->queue < 0 || task->queue >= queues->size) {
        ASSERT(0, "Tried to remove %s from invalid queue %d", task->name, task->queue);
    }
    array_m* raw = array_m_lookup(queues, task->queue);

    int idx = array_m_index(raw, task);
    if (idx < 0) {
        printf_err("Tried to dequeue %s from queue %d it didn't belong to!", task->name, task->queue);
        //fall back on searching all queues for this task
        for (int i = 0; i < queues->size; i++) {
            array_m* queue = array_m_lookup(queues, i);
            for (int j = 0; j < queue->size; j++) {
                task_t* tmp = array_m_lookup(queue, j);
                if (task == tmp) {
                    //found task we were looking for
                    printf_info("Task was actually in queue %d", i);
                    array_m_remove(queue, j);
                    unlock(mutex);

                    return;
                }
            }
        }
        //never found the task!
        printf_err("Task %s did not exist in any queues!", task->name);
        return;
    }

    array_m_remove(raw, idx);
    unlock(mutex);

    //if for some reason this task is still in the queue (if it was added to queue twice),
    //dequeue it again
    if (array_m_index(raw, task) != ARR_NOT_FOUND) {
        dequeue_task(task);
    }
}
Пример #4
0
void Get_data(void)
{
    int  len;
    int i;

    (void)time(&the_time);

    fp = fopen("sensordata.txt","a+");
    if(fp == NULL)
    {
        fprintf(stderr,"Open datafile error\n");
        exit(1);
    } 

    fputs(ctime(&the_time),fp);

    fputs("Room1 Light:\n",fp);
    len = sizeof(Sensor_light_Room1)/sizeof(Sensor_light_Room1[0]);
    Calc_data(Sensor_light_Room1,len);
    Write_into_file(room_info,len);
    for(i = 0; i < len; i++)
    {
        avge += room_info[i];
    }
    avge /= len;

    fputs("Room1:\n",fp);
    len = sizeof(Sensor_TrainRoom1)/sizeof(Sensor_TrainRoom1[0]);
    Calc_data(Sensor_TrainRoom1,len);
    Write_into_file(room_info,len);
    makeup_data(1,len);	

    //send the first two single sensor room
   //# single_sensor(room_info[0],4); //room_id is 4
    //#Send_data(2);
    //#sleep(3);
    //single_sensor(room_info[1],5); //room_id is 5
    //Send_data(2);
    //sleep(2);

    Send_data(1); //here used to send room1 data
	printf_info(1);
    sleep(3);

    fputs("Room2:\n",fp);
    len = sizeof(Sensor_TrainRoom2)/sizeof(Sensor_TrainRoom2[0]);
    Calc_data(Sensor_TrainRoom2,len);
    Write_into_file(room_info,len);
    // makeup_data(2,len);
    //Send_data(1); //room 2 data
	//printf_info(2); //print log info
    //sleep(3);
    fputs("Room3:\n",fp);
    len = sizeof(Sensor_TrainRoom3)/sizeof(Sensor_TrainRoom3[0]);
	Calc_data(Sensor_TrainRoom3,len);
	Write_into_file(room_info,len);
	//makeup_data(3,len);
	//Send_data(1); //room 3 data
	//printf_info(3);
	//sleep(3);
	fputs("\n",fp);
	fclose(fp);

}
Пример #5
0
/*
 *  Announce transfer rate if anything changed since last announcement.
 */
void sym_announce_transfer_rate(hcb_p np, int target)
{
	tcb_p tp = &np->target[target];

#define __tprev	tp->tinfo.prev
#define __tcurr	tp->tinfo.curr

	if (__tprev.options  == __tcurr.options &&
	    __tprev.width    == __tcurr.width   &&
	    __tprev.offset   == __tcurr.offset  &&
	    !(__tprev.offset && __tprev.period != __tcurr.period))
		return;

	__tprev.options  = __tcurr.options;
	__tprev.width    = __tcurr.width;
	__tprev.offset   = __tcurr.offset;
	__tprev.period   = __tcurr.period;

	if (__tcurr.offset && __tcurr.period) {
		u_int period, f10, mb10;
		char *scsi;

		period = f10 = mb10 = 0;
		scsi = "FAST-5";

		if (__tcurr.period <= 9) {
			scsi = "FAST-80";
			period = 125;
			mb10 = 1600;
		}
		else {
			if	(__tcurr.period <= 11) {
				scsi = "FAST-40";
				period = 250;
				if (__tcurr.period == 11)
					period = 303;
			}
			else if	(__tcurr.period < 25) {
				scsi = "FAST-20";
				if (__tcurr.period == 12)
					period = 500;
			}
			else if	(__tcurr.period <= 50) {
				scsi = "FAST-10";
			}
			if (!period)
				period = 40 * __tcurr.period;
			f10 = 100000 << (__tcurr.width ? 1 : 0);
			mb10 = (f10 + period/2) / period;
		}
		printf_info (
		    "%s:%d: %s %sSCSI %d.%d MB/s %s (%d.%d ns, offset %d)\n",
		    sym_name(np), target, scsi, __tcurr.width? "WIDE " : "",
		    mb10/10, mb10%10,
		    (__tcurr.options & PPR_OPT_DT) ? "DT" : "ST",
		    period/10, period%10, __tcurr.offset);
	}
	else
		printf_info ("%s:%d: %sasynchronous.\n", 
		             sym_name(np), target, __tcurr.width? "wide " : "");
}