예제 #1
0
int SQLITE_wrapper::insertTasks(string JobId, list<Task*> lpt)
{
	int ret;
	list<Task*>::iterator it = lpt.begin();
	for(   ; it != lpt.end() ; it++ )
	{
		ret = insertTask(JobId, *it);
	}
	return ret;
}
예제 #2
0
void
promote::TierScheduler<TASK>::run(std::size_t const maxTasks,
                                  bool const repeats)
{
    TASK* task(0);

    // Flush _addedTasks queue
    while( (task = Scheduler<TASK>::getAddedTask()) ) {
        insertTask(task);
    }

    if( _numTasks == 0 ) return;
    std::size_t const tierCount(_tiers.size());
    for(std::size_t processed = 0; processed < maxTasks; ) {
        std::size_t const count(++_counter);
        std::size_t tier(0);
        do {
            // Process tasks in current tier
            Queue<TASK*,false,false>* const tierTasks(_tiers[tier]);
            if( tierTasks ) {
                std::size_t const tierTaskCount(tierTasks->size());
                for(std::size_t jj = 0; jj != tierTaskCount; ++jj) {
                    tierTasks->read(task);
                    task->process();
                    ++processed;
                    if( task->completed() ) {
                        Scheduler<TASK>::releaseTask(task);
                        --_numTasks;
                        if( _numTasks == 0 ) {
                            return;
                        }
                    } else if( task->tier() == tier ) { // tier hasn't changed
                        tierTasks->write(task);
                    } else {
                        insertTask(task);
                    }
                }
            }
            ++tier;
        } while( (count & ((1 << tier) - 1)) == 0 and (tier < tierCount) );
    }
}
예제 #3
0
void registerFunctionWithOffset(struct Sched *sched, void (*f)(), uint32_t period, uint16_t priority, uint32_t offset){

	struct SchedTask *task;
	struct SchedTask *prev_task = sched->first_fn;

	task = createSchedFunction(f, period, priority, offset);

	if (sched->first_fn != NULL) {
		if (prev_task->priority > priority) {
			insertTask(sched, task, sched->first_fn);
		} else {
			while (prev_task->priority <= priority && prev_task != sched->last_fn)
				prev_task = prev_task->next_fn;
			appendTask(sched, task, prev_task);
		}
	} else {
		/* First task added */
		sched->first_fn = task;
		sched->last_fn = sched->first_fn;
	}
	sched->nb_fn++;
}
예제 #4
0
파일: B2Task.cpp 프로젝트: SBU-BMI/nscale
// does not keep data in GPU memory yet.  no appropriate flag to show that data is on GPU, so that execEngine can try to reuse.
bool B2Task::run(int procType, int tid) {
	// begin work
	int result;	

	printf("B2\n");

#if !defined (WITH_CUDA)
	procType = ExecEngineConstants::CPU;
#endif

	if (procType == ExecEngineConstants::GPU) {  // GPU

::cv::gpu::Stream stream;
		::cv::gpu::GpuMat g_input = ::cv::gpu::createContinuous(input.size(), input.type());

		stream.enqueueUpload(input, g_input);
		stream.waitForCompletion();


        // a 3x3 mat with a cross
        unsigned char disk3raw[9] = {
                        0, 1, 0,
                        1, 1, 1,
                        0, 1, 0};
        std::vector<unsigned char> disk3vec(disk3raw, disk3raw+9);
        ::cv::Mat disk3(disk3vec);
        // can't use morphologyEx.  the erode phase is not creating a border even though the method signature makes it appear that way.
        // because of this, and the fact that erode and dilate need different border values, have to do the erode and dilate myself.
        //      morphologyEx(seg_nohole, seg_open, CV_MOP_OPEN, disk3, ::cv::Point(1,1)); //, ::cv::Point(-1, -1), 1, ::cv::BORDER_REFLECT);
        disk3 = disk3.reshape(1, 3);
//      imwrite("test/out-rcopen-strel.pbm", disk19);
        // filter doesnot check borders.  so need to create border.
        ::cv::gpu::GpuMat g_output = ::nscale::gpu::morphOpen<unsigned char>(g_input, disk3, stream);

		result = ::nscale::HistologicalEntities::CONTINUE;
		stream.enqueueDownload(g_output, output);
		stream.waitForCompletion();

		g_input.release();
		g_output.release();

	} else if (procType == ExecEngineConstants::CPU) { // CPU
        ::cv::Mat disk3 = getStructuringElement(::cv::MORPH_ELLIPSE, ::cv::Size(3,3));

        // can't use morphologyEx.  the erode phase is not creating a border even though the method signature makes it appear that way.
        // because of this, and the fact that erode and dilate need different border values, have to do the erode and dilate myself.
        //      morphologyEx(seg_nohole, seg_open, CV_MOP_OPEN, disk3, ::cv::Point(1,1)); //, ::cv::Point(-1, -1), 1, ::cv::BORDER_REFLECT);
        output = ::nscale::morphOpen<unsigned char>(input, disk3);

		result = ::nscale::HistologicalEntities::CONTINUE;
	} else { // error
		printf("ERROR: invalid proc type");
		result = ::nscale::HistologicalEntities::RUNTIME_FAILED;
	}	


	//stage the next work
	if (result == ::nscale::HistologicalEntities::CONTINUE) {

	// now create the next task
		next = new A4Task(img, output, outfilename);
	// and invoke it (temporary until hook up the exec engine).
		if (insertTask(next) != 0) {
			printf("unable to insert task\n");
			return false;
		}
	}	
      return true;

}
예제 #5
0
int main() {
	/* Initialize hardware */
	// Turn off interrupt
	asm("msr 	CPSR_c, #0xd3");

	// Tune up the system
	enableCache();
	// speedUpCpu();

	// Setup UART2
	setUARTLineControl(UART2_BASE, 3, FALSE, FALSE, FALSE, FALSE, FALSE, 115200);
	setUARTControl(UART2_BASE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE);

	// Setup UART1
	setUARTLineControl(UART1_BASE, 3, FALSE, TRUE, FALSE, FALSE, FALSE, 2400);
	setUARTControl(UART1_BASE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE);

	// Setup timer
	setTimerLoadValue(TIMER1_BASE, TIMER_TICK_SIZE);
	setTimerControl(TIMER1_BASE, TRUE, TRUE, TRUE);
	setTimerControl(TIMER3_BASE, TRUE, FALSE, FALSE);

	// Enable interrupt
	enableVicInterrupt(VIC1_BASE, VIC_TIMER1_MASK);
	enableVicInterrupt(VIC2_BASE, VIC_UART2_MASK);
	enableVicInterrupt(VIC2_BASE, VIC_UART1_MASK);

	/* Initialize ReadyQueue and Task related data structures */
	KernelGlobal global;
	ReadyQueue	ready_queue;
	Heap		task_heap;
	HeapNode	*task_heap_data[TASK_PRIORITY_MAX];
	HeapNode	task_heap_nodes[TASK_PRIORITY_MAX];
	FreeList	free_list;
	Task		task_array[TASK_MAX];
	TaskList	task_list[TASK_PRIORITY_MAX];
	BlockedList	receive_blocked_lists[TASK_MAX];
	BlockedList	event_blocked_lists[EVENT_MAX];
	MsgBuffer	msg_array[TASK_MAX];
	char		stacks[TASK_MAX * TASK_STACK_SIZE];

	taskArrayInitial(task_array, stacks);
	freeListInitial(&free_list, task_array);
	heapInitial(&task_heap, task_heap_data, TASK_PRIORITY_MAX);
	readyQueueInitial(&ready_queue, &task_heap, task_heap_nodes, task_list);
	blockedListsInitial(receive_blocked_lists, TASK_MAX);
	blockedListsInitial(event_blocked_lists, EVENT_MAX);
	msgArrayInitial(msg_array);

	/* Setup global kernel entry */
	int *swi_entry = (int *) SWI_ENTRY_POINT;
	*swi_entry = (int) (TEXT_REG_BASE + swiEntry);
	int *irq_entry = (int *) IRQ_ENTRY_POINT;
	*irq_entry = (int) (TEXT_REG_BASE + irqEntry);

	/* Setup kernel global variable structure */
	global.ready_queue = &ready_queue;
	global.free_list = &free_list;
	global.receive_blocked_lists = receive_blocked_lists;
	global.event_blocked_lists = event_blocked_lists;
	global.msg_array = msg_array;
	global.task_array = task_array;

	kernelGlobalInitial(&global);

	/* Create first task with highest priority */
	Task *first_task = createTask(&free_list, 0, umain);
	insertTask(&ready_queue, first_task);

	/* Main syscall handling loop */
	while(1){
		// If no more task to run, break
		if(!scheduleNextTask(&ready_queue)) break;

		UserTrapframe* user_sp = (UserTrapframe *)ready_queue.curtask->current_sp;
		DEBUG(DB_TASK, "| TASK:\tEXITING SP: 0x%x SPSR: 0x%x ResumePoint: 0x%x\n", user_sp, user_sp->spsr, user_sp->resume_point);
		STAT_TASK_BEGIN(&global);

		// Exit kernel to let user program to execute
		kernelExit(ready_queue.curtask->current_sp);

		asm("mov r1, %0"
		    :
		    :"r"(&global)
		    :"r0", "r2", "r3"
		    );
		asm("bl	handlerRedirection(PLT)");
	}

	// printStat(&global);

	/* Turm off timer */
	setTimerControl(TIMER1_BASE, FALSE, FALSE, FALSE);
	setTimerControl(TIMER3_BASE, FALSE, FALSE, FALSE);

	return 0;
}
예제 #6
0
void QwwTaskPanel::insertTask(int index, QWidget * task, const QString & label) {
    insertTask(index, task, QIcon(), label);
}
예제 #7
0
void QwwTaskPanel::addTask(QWidget * task, const QIcon & icon, const QString & label) {
    insertTask(taskCount(), task, icon, label);
}
예제 #8
0
TodoNote::TodoNote(const QFileInfo& fileinfo, Note::Type type_new)
	: Note(fileinfo, type_new)
{
	text_edit = new TextEdit();
	text_edit->setAcceptRichText(false);
	text_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//	text_edit->setMinimumHeight(100);
//	text_edit->setMaximumHeight(200);

	model = new TodoModel();
	proxy_model = new TodoProxyModel();
	proxy_model->setSourceModel(model);

	tree_view = new QTreeView();
	tree_view->setModel(proxy_model);
	tree_view->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);
	tree_view->setSelectionBehavior(QAbstractItemView::SelectRows);
    tree_view->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
	tree_view->header()->hide();
	tree_view->setDragEnabled(true);
	tree_view->setAcceptDrops(true);
	tree_view->setDropIndicatorShown(true);
	tree_view->setDragDropMode(QAbstractItemView::InternalMove);
	tree_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);

	connect(proxy_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(taskChanged(QModelIndex)));
	connect(tree_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(taskChanged(QModelIndex)));

	tree_view->setContextMenuPolicy(Qt::CustomContextMenu);
	tree_view->setAnimated(true);

	connect(tree_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));

	menu_context = new QMenu();
	menu_context->addAction(tr("Insert new task"), this, SLOT(insertTask()));
	menu_context->addAction(tr("Insert new task"), this, SLOT(insertSubTask()));
	menu_context->addAction(tr("Remove this task"), this, SLOT(removeTask()));
	//menu_context->addAction(tr("Hide completed tasks"), this, SLOT(hideCompletedTasks()));
	//menu_context->actions()[TODO_ACTION_HIDE_COMPLETED]->setCheckable(true);

	for(int i=2; i<model->columnCount(); ++i)
		tree_view->setColumnHidden(i, true);

	lb_date_start = new QLabel;
	lb_date_0 = new QLabel(tr("Created: "), lb_date_start);
	lb_date_stop = new QLabel;
	lb_date_1 = new QLabel(tr("Completed: "), lb_date_stop);
	dt_date_limit = new QDateTimeEdit;
	dt_date_limit->setCalendarPopup(true);
	cb_date_limit = new QCheckBox(tr("Limited: "), dt_date_limit);
	cb_date_limit->setCheckable(true);

	grid_layout = new QGridLayout();
	QGridLayout* l = qobject_cast<QGridLayout*>(grid_layout);
	l->addWidget(lb_date_0, 0, 0);
	l->addWidget(lb_date_start, 0, 1);
	l->addWidget(lb_date_1, 1, 0);
	l->addWidget(lb_date_stop, 1, 1);
	l->addWidget(cb_date_limit, 2, 0);
	l->addWidget(dt_date_limit, 2, 1);

	extra_layout = new QVBoxLayout;
	extra_layout->addItem(grid_layout);
	extra_layout->addWidget(text_edit);

	extra_widget = new QWidget;
	extra_widget->setLayout(extra_layout);
	extra_widget->hide();

	main_layout = new QVBoxLayout();
	main_layout->addWidget(tree_view);
	main_layout->addWidget(extra_widget);

	area = new QScrollArea();
	area->setLayout(main_layout);

	load(); //loading note's content

	mapper = new QDataWidgetMapper();
	mapper->setModel(proxy_model);
	mapper->addMapping(text_edit, 6, "plainText");
	mapper->addMapping(lb_date_start, 2, "text");
	mapper->addMapping(lb_date_stop, 3, "text");
	lb_date_start->setLocale(settings.getLocale());
	dt_date_limit->setLocale(settings.getLocale());
	dt_date_limit->calendarWidget()->setLocale(settings.getLocale());

	tree_view->setCurrentIndex(QModelIndex());
}