Exemplo n.º 1
0
static void
on_fail(struct task_t* t, int timeout) {
    if (timeout == 0) {
        printf("task[%x] timeout fail\n", task_id(t));
    } else {
        printf("task[%x] fail\n", task_id(t));
    }
}
Exemplo n.º 2
0
void Thread::trace_stack(Stream* st) {
#if ENABLE_STACK_TRACE
#if ENABLE_ISOLATES
  TaskContext maybeSwitchTask(task_id());
  st->print_cr("task ID 0x%lx ", task_id());
#endif
  Frame fr(this);
  trace_stack_from(&fr, st);
#endif
}
 // Serilize Constructor
 MessageMergeProcess()
     : Message( PROTOCOL_VERSION , 171 , 0 )
 {
     task_id( "" );
     uri_list(  );
     merger( "" );
 }
Exemplo n.º 4
0
static int realtime_set_affinity(task_data *task) {
    cpu_set_t set;
    int err, cpu_nr, use_cpu = -1;

    pthread_getaffinity_np(extra_task_data[task_id(task)].thread,
			   sizeof(set), &set);
    if (task->cpu > -1) { // CPU set explicitly
	if (!CPU_ISSET(task->cpu, &set)) {
	    rtapi_print_msg(RTAPI_MSG_ERR, 
			    "RTAPI: ERROR: realtime_set_affinity(%s): "
			    "CPU %d not available\n",
			    task->name, task->cpu);
	    return -EINVAL;
	}
	use_cpu = task->cpu;
    } else {
	// select last CPU as default
	for (cpu_nr = CPU_SETSIZE - 1; cpu_nr >= 0; cpu_nr--) {
	    if (CPU_ISSET(cpu_nr, &set)) {
		use_cpu = cpu_nr;
		break;
	    }
	}
	if (use_cpu < 0) {
	    rtapi_print_msg(RTAPI_MSG_ERR,
			    "Unable to get ID of the last CPU\n");
	    return -EINVAL;
	}
	rtapi_print_msg(RTAPI_MSG_DBG, "task %s: using default CPU %d\n",
			task->name, use_cpu);
    }
    CPU_ZERO(&set);
    CPU_SET(use_cpu, &set);

    err = pthread_setaffinity_np(extra_task_data[task_id(task)].thread,
				 sizeof(set), &set);
    if (err) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"%d %s: Failed to set CPU affinity to CPU %d (%s)\n",
			task_id(task), task->name, use_cpu, strerror(errno));
	return -EINVAL;
    }
    rtapi_print_msg(RTAPI_MSG_DBG,
		    "realtime_set_affinity(): task %s assigned to CPU %d\n", 
		    task->name, use_cpu);
    return 0;
}
Exemplo n.º 5
0
void Thread::print_value_on(Stream* st) {
#if USE_DEBUG_PRINTING
  st->print("Thread 0x%lx (id=%d) ", obj(), id());
#if ENABLE_ISOLATES
  st->print("task ID 0x%lx ", task_id());
#endif
#endif
}
Exemplo n.º 6
0
bool XmppTaskIq::HandleStanza(const txmpp::XmlElement *stanza) {

  if (MatchResponseIq(stanza, txmpp::JID_EMPTY, task_id())) {
    QueueStanza(stanza);
    return true;
  }

  return false;
}
Exemplo n.º 7
0
 // Serilize Constructor
 MessageTaskDeliver()
     : Message( PROTOCOL_VERSION , 131 , 0 )
 {
     task_id( "" );
     uri_list(  );
     aligner( "" );
     sorter( "" );
     reference( "" );
 }
Exemplo n.º 8
0
int XmppTaskIq::ProcessStart() {

  set_task_id(GetClient()->NextId());

  txmpp::scoped_ptr<txmpp::XmlElement> privacy(
      MakeIq("get", txmpp::JID_EMPTY, task_id()));
  txmpp::XmlElement *query = new txmpp::XmlElement(txmpp::QN_PRIVACY_QUERY);
  privacy->AddElement(query);

  SendStanza(privacy.get());

  return STATE_RESPONSE;
}
Exemplo n.º 9
0
void TimerWidget::start() {
    uint64_t task_id(0);
    uint64_t project_id(0);
    QVariant data = ui->description->currentData();
    if (data.canConvert<AutocompleteView *>()) {
        AutocompleteView *view = data.value<AutocompleteView *>();
        task_id = view->TaskID;
        project_id = view->ProjectID;
    }
    TogglApi::instance->start(ui->description->currentText(),
                              ui->duration->text(),
                              task_id,
                              project_id);
}
Exemplo n.º 10
0
void CFileHandler::HandleClientFileDelOfflineReq(CImPduClientFileDelOfflineReq* pPdu)
{
	string from_id_url(pPdu->GetFromId(), pPdu->GetFromIdLen());
	string to_id_url(pPdu->GetToId(), pPdu->GetToIdLen());
	uint32_t from_id = urltoid(from_id_url.c_str());
	uint32_t to_id = urltoid(to_id_url.c_str());
    string task_id(pPdu->GetTaskId(), pPdu->GetTaskIdLen());
	log("HandleClientFileDelOfflineReq, %u->%u, task_id=%s\n", from_id, to_id, task_id.c_str());

	CDBServConn* pDbConn = get_db_serv_conn();
	if (pDbConn) {
		CImPduFileDelOfflineReq pdu(to_id, from_id, to_id, task_id.c_str());
		pDbConn->SendPdu(&pdu);
	}
}
Exemplo n.º 11
0
void CFileHandler::HandleClientFileAddOfflineReq(CImPduClientFileAddOfflineReq* pPdu)
{
	string from_id_url(pPdu->GetFromId(), pPdu->GetFromIdLen());
	string to_id_url(pPdu->GetToId(), pPdu->GetToIdLen());
    string task_id(pPdu->GetTaskId(), pPdu->GetTaskIdLen());
	string file_name(pPdu->GetFileName(), pPdu->GetFileNameLen());
	uint32_t file_size = pPdu->GetFileSize();
	uint32_t from_id = urltoid(from_id_url.c_str());
	uint32_t to_id = urltoid(to_id_url.c_str());
	log("HandleClientFileAddOfflineReq, %u->%u, task_id: %s, file_name: %s, size: %u \n",
			from_id, to_id, task_id.c_str(), file_name.c_str(), file_size);

	CDBServConn* pDbConn = get_db_serv_conn();
	if (pDbConn) {
		CImPduFileAddOfflineReq pdu(from_id, from_id, to_id, task_id.c_str(), file_name.c_str(), file_size);
		pDbConn->SendPdu(&pdu);
	}
}
Exemplo n.º 12
0
void CFileHandler::HandleFileNotify(CImPduFileNotify *pPdu)
{
    uint32_t from_user_id = pPdu->GetFromId();
    uint32_t to_user_id = pPdu->GetToId();
    string file_name(pPdu->GetFileName(), pPdu->GetFileNameLen());
    uint32_t file_size = pPdu->GetFileSize();
    string task_id(pPdu->GetTaskId(), pPdu->GetTaskIdLen());
    string listen_ip(pPdu->GetListenIp(), pPdu->GetListenIpLen());
    uint32_t listen_port = pPdu->GetListenPort();
    log("HandleFileNotify, from_id: %u, to_id: %u, file_name: %s, task_id: %s, file_server_ip: %s,\
        file_server_port: %u.\n", from_user_id, to_user_id, file_name.c_str(), task_id.c_str(),
        listen_ip.c_str(), listen_port);
    CImUser* pUser = CImUserManager::GetInstance()->GetImUserById(to_user_id);
    if (pUser) {
        CImPduClientFileNotify pdu(idtourl(from_user_id), idtourl(to_user_id), file_name.c_str(),
                                   file_size, task_id.c_str(), listen_ip.c_str(), listen_port);
        pUser->BroadcastPdu(&pdu);
    }
}
Exemplo n.º 13
0
int _rtapi_wait_hook(void) {
    struct timespec ts;
    task_data *task = rtapi_this_task();

    if (extra_task_data[task_id(task)].deleted)
	pthread_exit(0);

    clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME,
		    &extra_task_data[task_id(task)].next_time, NULL);
    _rtapi_advance_time(&extra_task_data[task_id(task)].next_time,
		       task->period, 0);
    clock_gettime(CLOCK_MONOTONIC, &ts);
    if (ts.tv_sec > extra_task_data[task_id(task)].next_time.tv_sec
	|| (ts.tv_sec == extra_task_data[task_id(task)].next_time.tv_sec
	    && ts.tv_nsec > extra_task_data[task_id(task)].next_time.tv_nsec)) {

	// timing went wrong:

	// update stats counters in thread status
	_rtapi_task_update_stats_hook();

	rtapi_threadstatus_t *ts =
	    &global_data->thread_status[task_id(task)];

	ts->flavor.rtpreempt.wait_errors++;

	rtapi_exception_detail_t detail = {0};
	detail.task_id = task_id(task);

#ifndef RTAPI_POSIX
	if (rt_exception_handler)
	    rt_exception_handler(RTP_DEADLINE_MISSED, &detail, ts);
#endif
    }
    return 0;
}
Exemplo n.º 14
0
ReturnOop Thread::task_for_thread( void ) const {
  return Task::get_task(task_id());
}
Exemplo n.º 15
0
static void
on_success(struct task_t* t) {
    printf("task[%x] success\n", task_id(t));
}
Exemplo n.º 16
0
 // Serilize Constructor
 MessageTaskPause()
     : Message( PROTOCOL_VERSION , 142 , 0 )
 {
     task_id( "" );
 }
Exemplo n.º 17
0
static void *realtime_thread(void *arg) {
    task_data *task = arg;

    rtapi_set_task(task);


    if (task->period < period)
	task->period = period;
    task->ratio = task->period / period;

    extra_task_data[task_id(task)].tid = (pid_t) syscall(SYS_gettid);

    rtapi_print_msg(RTAPI_MSG_INFO,
		    "RTAPI: task '%s' at %p period = %d ratio=%d id=%d TID=%d\n",
		    task->name,
		    task, task->period, task->ratio,
		    task_id(task), extra_task_data[task_id(task)].tid);

    if (realtime_set_affinity(task))
	goto error;
    if (realtime_set_priority(task)) {
#ifdef RTAPI_POSIX // This requires privs - tell user how to obtain them
	rtapi_print_msg(RTAPI_MSG_ERR, 
			"to get non-preemptive scheduling with POSIX threads,");
	rtapi_print_msg(RTAPI_MSG_ERR, 
			"you need to run 'sudo setcap cap_sys_nice=pe libexec/rtapi_app_posix'");
	rtapi_print_msg(RTAPI_MSG_ERR, 
			"your might have to install setcap (e.g.'sudo apt-get install libcap2-bin') to do this.");
#else
	goto error;
#endif
    }

    /* We're done initializing. Open the barrier. */
    pthread_barrier_wait(&extra_task_data[task_id(task)].thread_init_barrier);

    clock_gettime(CLOCK_MONOTONIC, &extra_task_data[task_id(task)].next_time);
    _rtapi_advance_time(&extra_task_data[task_id(task)].next_time,
		       task->period, 0);

    _rtapi_task_update_stats_hook(); // inital stats update

    /* The task should not pagefault at all. So record initial counts now.
     * Note that currently we _do_ receive a few pagefaults in the
     * taskcode init. This is noncritical and probably not worth
     * fixing. */
    {
	struct rusage ru;

	if (getrusage(RUSAGE_THREAD, &ru)) {
	    rtapi_print_msg(RTAPI_MSG_ERR,"getrusage(): %d - %s\n",
			    errno, strerror(-errno));
	} else {
	    rtapi_threadstatus_t *ts =
		&global_data->thread_status[task_id(task)];
	    ts->flavor.rtpreempt.startup_ru_nivcsw = ru.ru_nivcsw;
	    ts->flavor.rtpreempt.startup_ru_minflt = ru.ru_minflt;
	    ts->flavor.rtpreempt.startup_ru_majflt = ru.ru_majflt;
	}
    }

    /* call the task function with the task argument */
    task->taskcode(task->arg);

    rtapi_print_msg
	(RTAPI_MSG_ERR,
	 "ERROR: reached end of realtime thread for task %d\n",
	 task_id(task));
    extra_task_data[task_id(task)].deleted = 1;

    return NULL;
 error:
    /* Signal that we're dead and open the barrier. */
    extra_task_data[task_id(task)].deleted = 1;
    pthread_barrier_wait(&extra_task_data[task_id(task)].thread_init_barrier);
    return NULL;
}
void BodyTask (void * arg)
{
   printf ("Estou na tarefa %5d\n", task_id()) ;
   task_exit (0) ;
}