您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ thread_info函数代码示例

51自学网 2021-06-03 08:48:53
  C++
这篇教程C++ thread_info函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中thread_info函数的典型用法代码示例。如果您正苦于以下问题:C++ thread_info函数的具体用法?C++ thread_info怎么用?C++ thread_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了thread_info函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: resume_thread

int resume_thread(unsigned int thread){    int i;    kern_return_t ret;        unsigned int size = THREAD_BASIC_INFO_COUNT;    struct thread_basic_info info;        ret = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &size);	    if(ret != KERN_SUCCESS)    {        fprintf(stderr, "Failed to get thread info 1, got %d/n", ret);        // return ok for the case when the process is going away                return -1;        return 0;    }	    for(i = 0; i < info.suspend_count; i++)    {        ret = thread_resume(thread);        if(ret != KERN_SUCCESS)        {            fprintf(stderr, "Failed to get thread info 2, got %d/n", ret);            return -1;        }    }    return 0;}
开发者ID:reeth,项目名称:pydbg64,代码行数:29,


示例2: xbt_os_threadtimer_resume

void xbt_os_threadtimer_resume(xbt_os_timer_t timer){#if HAVE_POSIX_GETTIME  timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;  timer->elapse.tv_nsec += timer->stop.tv_nsec - timer->start.tv_nsec;  clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->start));#elif HAVE_GETTIMEOFDAY && defined(__MACH__) && defined(__APPLE__)  timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;  timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;  mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;  thread_basic_info_data_t thi_data;  thread_basic_info_t thi = &thi_data;  thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t)thi, &count);  timer->start.tv_usec =  thi->system_time.microseconds + thi->user_time.microseconds;  timer->start.tv_sec = thi->system_time.seconds + thi->user_time.seconds;#elif HAVE_GETTIMEOFDAY  timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;  timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;  gettimeofday(&(timer->start), NULL);#elif defined(_WIN32)  timer->elapse.tv_sec += timer->stop.tv_sec - timer->start.tv_sec;  timer->elapse.tv_usec += timer->stop.tv_usec - timer->start.tv_usec;  HANDLE h = GetCurrentThread();  FILETIME creationTime, exitTime, kernelTime, userTime;  GetThreadTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);  w32_times_to_timeval(&timer->start, &kernelTime, &userTime);#endif}
开发者ID:mpoquet,项目名称:simgrid,代码行数:28,


示例3: getCPUTime

// Returns the time the current thread has spent executing, in milliseconds.static inline unsigned getCPUTime(){#if OS(DARWIN)    mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT;    thread_basic_info_data_t info;    // Get thread information    mach_port_t threadPort = mach_thread_self();    thread_info(threadPort, THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount);    mach_port_deallocate(mach_task_self(), threadPort);        unsigned time = info.user_time.seconds * 1000 + info.user_time.microseconds / 1000;    time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000;        return time;#elif OS(WINDOWS)    union {        FILETIME fileTime;        unsigned long long fileTimeAsLong;    } userTime, kernelTime;        // GetThreadTimes won't accept NULL arguments so we pass these even though    // they're not used.    FILETIME creationTime, exitTime;        GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime);        return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000;#else    // FIXME: We should return the time the current thread has spent executing.    return currentTime() * 1000;#endif}
开发者ID:cedrus,项目名称:qt4,代码行数:34,


示例4: thread_info

nub_addr_t MachThread::GetPThreadT() {  nub_addr_t pthread_t_value = INVALID_NUB_ADDRESS;  if (MachPortNumberIsValid(m_mach_port_number)) {    kern_return_t kr;    thread_identifier_info_data_t tident;    mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;    kr = thread_info(m_mach_port_number, THREAD_IDENTIFIER_INFO,                     (thread_info_t)&tident, &tident_count);    if (kr == KERN_SUCCESS) {      // Dereference thread_handle to get the pthread_t value for this thread.      if (m_is_64_bit) {        uint64_t addr;        if (m_process->ReadMemory(tident.thread_handle, 8, &addr) == 8) {          if (addr != 0) {            pthread_t_value = addr;          }        }      } else {        uint32_t addr;        if (m_process->ReadMemory(tident.thread_handle, 4, &addr) == 4) {          if (addr != 0) {            pthread_t_value = addr;          }        }      }    }  }  return pthread_t_value;}
开发者ID:emaste,项目名称:lldb,代码行数:29,


示例5: thread_cpu_usage

int thread_cpu_usage(uint64_t* user, uint64_t* system) {#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050    mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;    thread_basic_info_data_t info;    kern_return_t err;    mach_port_t port = mach_thread_self();    err = thread_info(port, THREAD_BASIC_INFO, (thread_info_t)&info, &count);    mach_port_deallocate(mach_task_self(), port);    if(err == KERN_SUCCESS) {        *user   = (uint64_t) info.user_time.seconds * 1000000 + info.user_time.microseconds;        *system = (uint64_t) info.system_time.seconds * 1000000 + info.system_time.microseconds;        return 0;    }    return -1;#elif defined(RUSAGE_THREAD)    struct rusage buf;    if(getrusage(RUSAGE_THREAD, &buf)) return -1;    *user   = (uint64_t)buf.ru_utime.tv_sec * 1000000 + buf.ru_utime.tv_usec;    *system = (uint64_t)buf.ru_stime.tv_sec * 1000000 + buf.ru_stime.tv_usec;    return 0;#elif defined(_WIN32)    FILETIME unused, unused2;    FILETIME sys, usr;    GetThreadTimes(GetCurrentThread(), &unused, &unused2, &sys, &user);    *user   = (((uint64_t) usr.dwHighDateTime) << 32) + usr.dwLowDateTime;    *system = (((uint64_t) sys.dwHighDateTime) << 32) + sys.dwLowDateTime;    return 0;#else    return -1;#endif}
开发者ID:andre-richter,项目名称:rubinius,代码行数:33,


示例6: GetThreadTimes

BOOL WINAPI GetThreadTimes (  HANDLE hThread,  LPFILETIME lpCreationTime,  LPFILETIME lpExitTime,  LPFILETIME lpKernelTime,  LPFILETIME lpUserTime) {  if (!hThread)    return false;  if (!hThread->m_threadValid)    return false;  if (hThread == (HANDLE)-1) {    if (lpCreationTime)      TimeTToFileTime(0,lpCreationTime);    if (lpExitTime)      TimeTToFileTime(time(NULL),lpExitTime);    if (lpKernelTime)      TimeTToFileTime(0,lpKernelTime);    if (lpUserTime)      TimeTToFileTime(0,lpUserTime);    return true;  }  if (lpCreationTime)    TimeTToFileTime(hThread->m_tmCreation,lpCreationTime);  if (lpExitTime)    TimeTToFileTime(time(NULL),lpExitTime);  if (lpKernelTime)    TimeTToFileTime(0,lpKernelTime);#ifdef __APPLE__  thread_info_data_t     threadInfo;  mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;  if (hThread->m_machThreadPort == MACH_PORT_NULL)    hThread->m_machThreadPort = pthread_mach_thread_np(hThread->m_hThread);  kern_return_t ret = thread_info(hThread->m_machThreadPort, THREAD_BASIC_INFO, (thread_info_t)threadInfo, &threadInfoCount);  if (ret == KERN_SUCCESS)  {    thread_basic_info_t threadBasicInfo = (thread_basic_info_t)threadInfo;    if (lpUserTime)    {      // User time.      unsigned long long time = ((__int64)threadBasicInfo->user_time.seconds * 10000000L) + threadBasicInfo->user_time.microseconds*10L;      lpUserTime->dwLowDateTime = (time & 0xFFFFFFFF);      lpUserTime->dwHighDateTime = (time >> 32);    }    if (lpKernelTime)    {      // System time.      unsigned long long time = ((__int64)threadBasicInfo->system_time.seconds * 10000000L) + threadBasicInfo->system_time.microseconds*10L;      lpKernelTime->dwLowDateTime = (time & 0xFFFFFFFF);      lpKernelTime->dwHighDateTime = (time >> 32);    }  }
开发者ID:mbolhuis,项目名称:xbmc,代码行数:60,


示例7: info_mach_thread_command

static voidinfo_mach_thread_command (char *args, int from_tty){  union  {    struct thread_basic_info basic;  } thread_info_data;  thread_t thread;  kern_return_t result;  unsigned int info_count;  CHECK_ARGS (_("Thread"), args);  sscanf (args, "0x%x", &thread);  printf_unfiltered (_("THREAD_BASIC_INFO/n"));  info_count = THREAD_BASIC_INFO_COUNT;  result = thread_info (thread,			THREAD_BASIC_INFO,			(thread_info_t) & thread_info_data.basic,			&info_count);  MACH_CHECK_ERROR (result);#if 0  PRINT_FIELD (&thread_info_data.basic, user_time);  PRINT_FIELD (&thread_info_data.basic, system_time);#endif  PRINT_FIELD (&thread_info_data.basic, cpu_usage);  PRINT_FIELD (&thread_info_data.basic, run_state);  PRINT_FIELD (&thread_info_data.basic, flags);  PRINT_FIELD (&thread_info_data.basic, suspend_count);  PRINT_FIELD (&thread_info_data.basic, sleep_time);}
开发者ID:kraj,项目名称:binutils-gdb,代码行数:33,


示例8: xbt_os_threadtimer_stop

void xbt_os_threadtimer_stop(xbt_os_timer_t timer){#ifdef HAVE_POSIX_GETTIME    clock_gettime(CLOCK_THREAD_CPUTIME_ID, &(timer->stop));#elif defined(HAVE_GETTIMEOFDAY) && defined(__MACH__) && defined(__APPLE__)    mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;    thread_basic_info_data_t thi_data;    thread_basic_info_t thi = &thi_data;    thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t)thi, &count);    timer->stop.tv_usec =  thi->system_time.microseconds + thi->user_time.microseconds;    timer->stop.tv_sec = thi->system_time.seconds + thi->user_time.seconds;#elif defined(HAVE_GETTIMEOFDAY)//if nothing else is available, return just time    gettimeofday(&(timer->stop), NULL);#elif defined(_XBT_WIN32)#  if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400)    THROW_UNIMPLEMENTED;#  else    HANDLE h = GetCurrentThread();    FILETIME creationTime, exitTime, kernelTime, userTime;    GetThreadTimes(h, &creationTime, &exitTime, &kernelTime, &userTime);    unsigned __int64 ktm, utm;    ktm = (unsigned __int64) kernelTime.dwHighDateTime << 32;    ktm |= kernelTime.dwLowDateTime;    ktm /= 10;    utm = (unsigned __int64) userTime.dwHighDateTime << 32;    utm |= userTime.dwLowDateTime;    utm /= 10;    timer->stop.tv_sec = (long) (ktm / 1000000L) + (long) (utm / 1000000L);    timer->stop.tv_usec = (long) (ktm % 1000000L) + (long) (utm % 1000000L);#  endif                        /* windows version checker */#endif}
开发者ID:FlorianPO,项目名称:simgrid,代码行数:32,


示例9: getrusage

void ProcessorMetric::UpdateTimeInt(double &user_time, double &system_time) {#ifdef RUSAGE_THREAD  // RUSAGE_THREAD is Linux-specific.  struct rusage usage;  int ret = getrusage(RUSAGE_THREAD, &usage);   if (ret != 0) {    throw StatException("Error getting resource usage");  }  user_time = GetMilliSec(usage.ru_utime);  system_time = GetMilliSec(usage.ru_stime);#else // https://stackoverflow.com/questions/13893134/get-current-pthread-cpu-usage-mac-os-x  mach_port_t thread = mach_thread_self();  thread_basic_info_data_t info;  mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;  kern_return_t kr = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &count);  if (kr == KERN_SUCCESS && (info.flags & TH_FLAGS_IDLE) == 0) {    user_time = ((double) info.user_time.microseconds) / 1000;    system_time = ((double) info.system_time.microseconds) / 1000;  }  else {    throw StatException("Error getting resource usage");  }  mach_port_deallocate(mach_task_self(), thread);#endif}
开发者ID:apavlo,项目名称:peloton,代码行数:26,


示例10: _dispatch_introspection_init

void_dispatch_introspection_init(void){	TAILQ_INSERT_TAIL(&_dispatch_introspection_queues,			&_dispatch_main_q, diq_list);	TAILQ_INSERT_TAIL(&_dispatch_introspection_queues,			&_dispatch_mgr_q, diq_list);#if DISPATCH_ENABLE_PTHREAD_ROOT_QUEUES	TAILQ_INSERT_TAIL(&_dispatch_introspection_queues,			_dispatch_mgr_q.do_targetq, diq_list);#endif	for (size_t i = 0; i < DISPATCH_ROOT_QUEUE_COUNT; i++) {		TAILQ_INSERT_TAIL(&_dispatch_introspection_queues,				&_dispatch_root_queues[i], diq_list);	}	// Hack to determine queue TSD offset from start of pthread structure	uintptr_t thread = _dispatch_thread_self();	thread_identifier_info_data_t tiid;	mach_msg_type_number_t cnt = THREAD_IDENTIFIER_INFO_COUNT;	kern_return_t kr = thread_info(pthread_mach_thread_np((void*)thread),			THREAD_IDENTIFIER_INFO, (thread_info_t)&tiid, &cnt);	if (!dispatch_assume_zero(kr)) {		_dispatch_introspection_thread_queue_offset =				(void*)(uintptr_t)tiid.dispatch_qaddr - (void*)thread;	}	_dispatch_thread_key_create(&dispatch_introspection_key,			_dispatch_introspection_thread_remove);	_dispatch_introspection_thread_add(); // add main thread}
开发者ID:AlexShiLucky,项目名称:swift-corelibs-libdispatch,代码行数:30,


示例11: tickcount

long longtickcount(void){    long long rc;    rc = 0;    if (g_clock_type == CPU_CLOCK) {        kern_return_t kr;        thread_basic_info_t tinfo_b;        thread_info_data_t tinfo_d;        mach_msg_type_number_t tinfo_cnt;        tinfo_cnt = THREAD_INFO_MAX;        kr = thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t)tinfo_d, &tinfo_cnt);        tinfo_b = (thread_basic_info_t)tinfo_d;        if (!(tinfo_b->flags & TH_FLAGS_IDLE))        {            rc = (tinfo_b->user_time.seconds + tinfo_b->system_time.seconds);            rc = (rc * 1000000) + (tinfo_b->user_time.microseconds + tinfo_b->system_time.microseconds);        }    } else if (g_clock_type == WALL_CLOCK) {        rc = gettimeofday_usec();    }    return rc;}
开发者ID:nirs,项目名称:yappi,代码行数:26,


示例12: ksmach_getThreadQueueName

bool ksmach_getThreadQueueName(const thread_t thread,                               char* const buffer,                               size_t bufLength){    // WARNING: This implementation is no longer async-safe!    integer_t infoBuffer[THREAD_IDENTIFIER_INFO_COUNT] = {0};    thread_info_t info = infoBuffer;    mach_msg_type_number_t inOutSize = THREAD_IDENTIFIER_INFO_COUNT;    kern_return_t kr = 0;    kr = thread_info(thread, THREAD_IDENTIFIER_INFO, info, &inOutSize);    if(kr != KERN_SUCCESS)    {        KSLOG_TRACE("Error getting thread_info with flavor THREAD_IDENTIFIER_INFO from mach thread : %s", mach_error_string(kr));        return false;    }    thread_identifier_info_t idInfo = (thread_identifier_info_t)info;    dispatch_queue_t* dispatch_queue_ptr = (dispatch_queue_t*)idInfo->dispatch_qaddr;    //thread_handle shouldn't be 0 also, because    //identifier_info->dispatch_qaddr =  identifier_info->thread_handle + get_dispatchqueue_offset_from_proc(thread->task->bsd_info);    if(dispatch_queue_ptr == NULL || idInfo->thread_handle == 0 || *dispatch_queue_ptr == NULL)    {        KSLOG_TRACE("This thread doesn't have a dispatch queue attached : %p", thread);        return false;    }    dispatch_queue_t dispatch_queue = *dispatch_queue_ptr;    const char* queue_name = dispatch_queue_get_label(dispatch_queue);    if(queue_name == NULL)    {        KSLOG_TRACE("Error while getting dispatch queue name : %p", dispatch_queue);        return false;    }    KSLOG_TRACE("Dispatch queue name: %s", queue_name);    size_t length = strlen(queue_name);    // Queue label must be a null terminated string.    size_t iLabel;    for(iLabel = 0; iLabel < length + 1; iLabel++)    {        if(queue_name[iLabel] < ' ' || queue_name[iLabel] > '~')        {            break;        }    }    if(queue_name[iLabel] != 0)    {        // Found a non-null, invalid char.        KSLOG_TRACE("Queue label contains invalid chars");        return false;    }    bufLength = MIN(length, bufLength - 1);//just strlen, without null-terminator    strncpy(buffer, queue_name, bufLength);    buffer[bufLength] = 0;//terminate string    KSLOG_TRACE("Queue label = %s", buffer);    return true;}
开发者ID:AisakaTiger,项目名称:KSCrash,代码行数:59,


示例13: sys_info

/* * Get system information */intsys_info(int type, void *buf){    struct info_memory infomem;    struct info_timer infotmr;    struct info_thread infothr;    struct info_device infodev;    int err = 0;    if (buf == NULL || !user_area(buf))        return EFAULT;    sched_lock();    switch (type) {    case INFO_KERNEL:        err = umem_copyout(&infokern, buf, sizeof(infokern));        break;    case INFO_MEMORY:        page_info(&infomem);        kpage_info(&infomem);        err = umem_copyout(&infomem, buf, sizeof(infomem));        break;    case INFO_THREAD:        if (umem_copyin(buf, &infothr, sizeof(infothr))) {            err = EFAULT;            break;        }        if ((err = thread_info(&infothr)))            break;        infothr.cookie++;        err = umem_copyout(&infothr, buf, sizeof(infothr));        break;    case INFO_DEVICE:        if (umem_copyin(buf, &infodev, sizeof(infodev))) {            err = EFAULT;            break;        }        if ((err = device_info(&infodev)))            break;        infodev.cookie++;        err = umem_copyout(&infodev, buf, sizeof(infodev));        break;    case INFO_TIMER:        timer_info(&infotmr);        err = umem_copyout(&infotmr, buf, sizeof(infotmr));        break;    default:        err = EINVAL;        break;    }    sched_unlock();    return err;}
开发者ID:AndrewD,项目名称:prex,代码行数:62,


示例14: while

DWORD FileProcessor::Run(LPVOID /*arg*/){	if( PP ){	 FileEntry entry;		nProcessed = 0;		while( !PP->quitRequested() && (isBackwards ? PP->getBack(entry) : PP->getFront(entry)) ){		 // create a scoped lock without closing it immediately		 CRITSECTLOCK::Scope scp(PP->ioLock, 0);			scope = &scp;			currentEntry = &entry;			_InterlockedIncrement(&PP->nProcessing);			entry.compress( this, PP );			_InterlockedDecrement(&PP->nProcessing);			_InterlockedIncrement(&PP->nProcessed);			currentEntry = NULL;			nProcessed += 1;			scope = NULL;			runningTotalRaw += entry.fileInfo.st_size;			runningTotalCompressed += (entry.compressedSize > 0)? entry.compressedSize : entry.fileInfo.st_size;			/*if( PP->verbose() > 1 )*/{#if defined(__MACH__)                mach_port_t thread = mach_thread_self();				mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;				thread_basic_info_data_t info;				int kr = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t) &info, &count);				if( kr == KERN_SUCCESS ){					 userTime = info.user_time.seconds + info.user_time.microseconds * 1e-6;					 systemTime = info.system_time.seconds + info.system_time.microseconds * 1e-6;					 avCPUUsage += info.cpu_usage * 100.0 / TH_USAGE_SCALE;					 threadInfo = info;					 hasInfo = true;				}				mach_port_deallocate(mach_task_self(), thread);#elif defined(linux)				struct rusage rtu;				if (!getrusage(RUSAGE_THREAD, &rtu)) {					const auto ut = rtu.ru_utime.tv_sec + rtu.ru_utime.tv_usec * 1e-6;					const auto st = rtu.ru_stime.tv_sec + rtu.ru_stime.tv_usec * 1e-6;					if (ut >= 0 && st >= 0) {						userTime = ut, systemTime = st, hasInfo = true;					}				}#	ifdef CLOCK_THREAD_CPUTIME_ID				struct timespec ts;				if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != -1) {					cpuTime = ts.tv_sec + ts.tv_nsec * 1e-9;					double t = userTime + systemTime;					if (cpuTime > 0) {						avCPUUsage += t * 100.0 / cpuTime;					}				}#	endif#endif			}		}	}	return DWORD(nProcessed);}
开发者ID:RJVB,项目名称:afsctool,代码行数:59,


示例15: thread_info

void Message::operator()() {	if ( num % 5 == 0) {		// int j = 1 / (i % 5);		throw boost::enable_current_exception(thread_error()) << thread_info("Whazzup?");	} else {		Logger::log(info, str());	}}
开发者ID:GMcD,项目名称:consumer-producer,代码行数:8,


示例16: chudxnu_thread_info

__private_extern__kern_return_t chudxnu_thread_info(thread_act_t thr_act,        						thread_flavor_t flavor,        						thread_info_t thread_info_out,        						mach_msg_type_number_t *thread_info_count){	return thread_info(thr_act, flavor, thread_info_out, thread_info_count);}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:8,


示例17: detach

//------------------------------------------------------------------------------// Name: open// Desc://------------------------------------------------------------------------------bool DebuggerCore::open(const QString &path, const QString &cwd, const QList<QByteArray> &args, const QString &tty) {	detach();	pid_t pid;	switch(pid = fork()) {	case 0:		// we are in the child now...		// set ourselves (the child proc) up to be traced		ptrace(PT_TRACE_ME, 0, 0, 0);		// redirect it's I/O		if(!tty.isEmpty()) {			FILE *const std_out = freopen(qPrintable(tty), "r+b", stdout);			FILE *const std_in  = freopen(qPrintable(tty), "r+b", stdin);			FILE *const std_err = freopen(qPrintable(tty), "r+b", stderr);			Q_UNUSED(std_out);			Q_UNUSED(std_in);			Q_UNUSED(std_err);		}		// do the actual exec		execute_process(path, cwd, args);		// we should never get here!		abort();		break;	case -1:		// error!		pid_ = 0;		return false;	default:		// parent		do {			threads_.clear();			int status;			if(native::waitpid(pid, &status, 0) == -1) {				return false;			}			// the very first event should be a STOP of type SIGTRAP			if(!WIFSTOPPED(status) || WSTOPSIG(status) != SIGTRAP) {				detach();				return false;			}			// setup the first event data for the primary thread			threads_.insert(pid, thread_info());			pid_                 = pid;			active_thread_       = pid;			threads_[pid].status = status;			return true;		} while(0);		break;	}}
开发者ID:Jmdebugger,项目名称:edb-debugger,代码行数:62,


示例18: thread_parse_child_update_response

static void thread_parse_child_update_response(protocol_interface_info_entry_t *cur, mle_message_t *mle_msg, mle_security_header_t *security_headers, uint8_t linkMargin){    uint8_t mode;    uint32_t timeout;    mle_neigh_table_entry_t *entry_temp;    thread_leader_data_t leaderData = {0};    uint8_t status;    bool leader_data_received;    tr_debug("Child Update Response");    leader_data_received = thread_leader_data_parse(mle_msg->data_ptr, mle_msg->data_length, &leaderData);    entry_temp = mle_class_get_entry_by_ll64(cur->id, linkMargin, mle_msg->packet_src_address, false);    if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status) &&        status == 1 && thread_check_is_this_my_parent(cur, entry_temp)) {        tr_debug("parent has connection error");        thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);        return;    }    if (!entry_temp) {        tr_debug("Not Neighbor");        mle_tlv_info_t challengeTlv;        mle_tlv_read_tlv(MLE_TYPE_CHALLENGE, mle_msg->data_ptr, mle_msg->data_length, &challengeTlv);        thread_host_bootstrap_child_update_negative_response(cur, mle_msg->packet_src_address, &challengeTlv);        return;    }    if ((security_headers->KeyIdMode == MAC_KEY_ID_MODE_SRC4_IDX)            && (thread_instance_id_matches(cur, &leaderData))) {        thread_management_key_synch_req(cur->id, common_read_32_bit(security_headers->Keysource));    } else {        tr_debug("Key ID Mode 2 not used; dropped.");        return;    }    if (!mle_tlv_read_8_bit_tlv(MLE_TYPE_MODE, mle_msg->data_ptr, mle_msg->data_length, &mode)) {        tr_debug("No Mode");        return;    }    if (mle_tlv_read_32_bit_tlv(MLE_TYPE_TIMEOUT, mle_msg->data_ptr, mle_msg->data_length, &timeout)) {        entry_temp->holdTime = 90;        tr_debug("Setting child timeout, value=%"PRIu32, timeout);        mle_entry_timeout_update(entry_temp, timeout);        thread_info(cur)->thread_endnode_parent->childUpdateProcessStatus = true;    }    tr_debug("Keep-Alive -->Respond from Parent");    mle_entry_timeout_refresh(entry_temp);    //Save possible new Leader Data    if (leader_data_received) {        thread_save_leader_data(cur, &leaderData);    }    mac_data_poll_protocol_poll_mode_decrement(cur);}
开发者ID:OpenNuvoton,项目名称:mbed,代码行数:57,


示例19: thread_info

UInt32 ZKMORHP_ForeignThread::getScheduledPriority(pthread_t inThread, int inPriorityKind){    thread_basic_info_data_t			threadInfo;	policy_info_data_t					thePolicyInfo;	unsigned int						count;	if (inThread == NULL)		return 0;        // get basic info    count = THREAD_BASIC_INFO_COUNT;    thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (thread_info_t)&threadInfo, &count);    	switch (threadInfo.policy) {		case POLICY_TIMESHARE:			count = POLICY_TIMESHARE_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&(thePolicyInfo.ts), &count);            if (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) {                return thePolicyInfo.ts.cur_priority;            }            return thePolicyInfo.ts.base_priority;            break;                    case POLICY_FIFO:			count = POLICY_FIFO_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (thread_info_t)&(thePolicyInfo.fifo), &count);            if ( (thePolicyInfo.fifo.depressed) && (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) ) {                return thePolicyInfo.fifo.depress_priority;            }            return thePolicyInfo.fifo.base_priority;            break;            		case POLICY_RR:			count = POLICY_RR_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (thread_info_t)&(thePolicyInfo.rr), &count);			if ( (thePolicyInfo.rr.depressed) && (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) ) {                return thePolicyInfo.rr.depress_priority;            }            return thePolicyInfo.rr.base_priority;            break;	}        return 0;}
开发者ID:paulz,项目名称:zirkonium,代码行数:44,


示例20: thread_host_child_update_response_send

static int thread_host_child_update_response_send(protocol_interface_info_entry_t *cur, uint8_t *dst_address, mle_tlv_info_t *challengeTlv, mle_tlv_info_t *requestTlv){    uint16_t len = 150 + 64;    uint8_t mode;    uint32_t keySequence;    uint8_t *ptr;    if (!thread_info(cur)) {        return -1;    }    uint16_t bufId = mle_service_msg_allocate(cur->id, len, false, MLE_COMMAND_CHILD_UPDATE_RESPONSE);    if (bufId == 0) {        return -1;    }    tr_debug("MLE Child update response");    thread_management_get_current_keysequence(cur->id, &keySequence);    mle_service_msg_update_security_params(bufId, 5, 2, keySequence);    ptr = mle_service_get_data_pointer(bufId);    mode = thread_mode_get_by_interface_ptr(cur);    //Write Mode Allways    ptr = mle_tlv_write_mode(ptr, mode);    //Set SRC    ptr = mle_general_write_source_address(ptr, cur);    //SET leader data    ptr = thread_leader_data_tlv_write(ptr, cur);    //Set Addresss TLV    if (requestTlv && mle_tlv_requested(requestTlv->dataPtr,requestTlv->tlvLen,MLE_TYPE_ADDRESS_REGISTRATION) &&          (mode & MLE_FFD_DEV) == 0) {        ptr = thread_address_registration_tlv_write(ptr, cur);    }    if (requestTlv && mle_tlv_requested(requestTlv->dataPtr,requestTlv->tlvLen,MLE_TYPE_TIMEOUT)) {        ptr = mle_tlv_write_timeout(ptr, cur->thread_info->host_link_timeout);    }    if (challengeTlv && challengeTlv->tlvLen) {        ptr = mle_tlv_write_response(ptr, challengeTlv->dataPtr, challengeTlv->tlvLen);        ptr = mle_general_write_link_layer_framecounter(ptr, cur);        //SET MLE Frame Counter        ptr = mle_tlv_write_framecounter(ptr, mle_service_security_get_frame_counter(cur->id));    }    if (mle_service_update_length_by_ptr(bufId,ptr)!= 0) {        tr_debug("Buffer overflow at message write");    }    mle_service_set_msg_destination_address(bufId, dst_address);    mle_service_send_message(bufId);    return 0;}
开发者ID:OpenNuvoton,项目名称:mbed,代码行数:56,


示例21: get_messenger

// Get the messenger from thread informationstatic messenger_t* get_messenger(){	messenger_t* msger;	THREAD_INFO* ti = thread_info();	msger = ti->messenger;	if( !msger )		ti->messenger = msger = (messenger_t*)			malloc(sizeof(messenger_t));	return msger;}
开发者ID:Ga-vin,项目名称:sgos,代码行数:11,


示例22: _getThreadPriority

UInt32 _getThreadPriority (pthread_t inThread, int inWhichPriority){    thread_basic_info_data_t			threadInfo;	policy_info_data_t					thePolicyInfo;	unsigned int						count;        // get basic info    count = THREAD_BASIC_INFO_COUNT;    thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (thread_info_t)&threadInfo, &count);    	switch (threadInfo.policy) {		case POLICY_TIMESHARE:			count = POLICY_TIMESHARE_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&(thePolicyInfo.ts), &count);            if (inWhichPriority == THREAD_SCHEDULED_PRIORITY) {                return thePolicyInfo.ts.cur_priority;            } else {                return thePolicyInfo.ts.base_priority;            }            break;                    case POLICY_FIFO:			count = POLICY_FIFO_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (thread_info_t)&(thePolicyInfo.fifo), &count);            if ( (thePolicyInfo.fifo.depressed) && (inWhichPriority == THREAD_SCHEDULED_PRIORITY) ) {                return thePolicyInfo.fifo.depress_priority;            }            return thePolicyInfo.fifo.base_priority;            break;            		case POLICY_RR:			count = POLICY_RR_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (thread_info_t)&(thePolicyInfo.rr), &count);			if ( (thePolicyInfo.rr.depressed) && (inWhichPriority == THREAD_SCHEDULED_PRIORITY) ) {                return thePolicyInfo.rr.depress_priority;            }            return thePolicyInfo.rr.base_priority;            break;	}        return 0;}
开发者ID:fruitsamples,项目名称:HAL,代码行数:42,


示例23: rtSchedDarwinGetBasePriority

/** * Get's the priority information for the current thread. * * @returns The base priority */static int rtSchedDarwinGetBasePriority(void){    /* the base_priority. */    mach_msg_type_number_t              Count = POLICY_TIMESHARE_INFO_COUNT;    struct policy_timeshare_info        TSInfo = {0,0,0,0,0};    kern_return_t                       krc;    krc = thread_info(mach_thread_self(), THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&TSInfo, &Count);    Assert(krc == KERN_SUCCESS);    return TSInfo.base_priority;}
开发者ID:jeppeter,项目名称:vbox,代码行数:16,


示例24: thread_info

Seconds CPUTime::forCurrentThread(){    mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT;    thread_basic_info_data_t info;    auto threadPort = MachSendRight::adopt(mach_thread_self());    auto ret = thread_info(threadPort.sendRight(), THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount);    RELEASE_ASSERT(ret == KERN_SUCCESS);    return Seconds(info.user_time.seconds + info.system_time.seconds) + Seconds::fromMicroseconds(info.user_time.microseconds + info.system_time.microseconds);}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:11,


示例25: thread_info

UInt32	FileReaderThread::GetThreadBasePriority (pthread_t inThread){    thread_basic_info_data_t			threadInfo;	policy_info_data_t					thePolicyInfo;	unsigned int						count;        // get basic info    count = THREAD_BASIC_INFO_COUNT;    thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (integer_t*)&threadInfo, &count);    	switch (threadInfo.policy) {		case POLICY_TIMESHARE:			count = POLICY_TIMESHARE_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (integer_t*)&(thePolicyInfo.ts), &count);			return thePolicyInfo.ts.base_priority;            break;                    case POLICY_FIFO:			count = POLICY_FIFO_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (integer_t*)&(thePolicyInfo.fifo), &count);            if (thePolicyInfo.fifo.depressed) {                return thePolicyInfo.fifo.depress_priority;            } else {                return thePolicyInfo.fifo.base_priority;            }            break;            		case POLICY_RR:			count = POLICY_RR_INFO_COUNT;			thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (integer_t*)&(thePolicyInfo.rr), &count);			if (thePolicyInfo.rr.depressed) {                return thePolicyInfo.rr.depress_priority;            } else {                return thePolicyInfo.rr.base_priority;            }            break;	}        return 0;}
开发者ID:fruitsamples,项目名称:PublicUtility,代码行数:40,


示例26: threadstart

// If thread t is suspended, start it up again.// If singlestep is set, only let it execute one instruction.static intthreadstart(Thread *t, int singlestep){	int i;	uint n;	struct thread_basic_info info;	if(!threadstopped(t))		return 0;	// Set or clear the processor single-step flag, as appropriate.	if(mach == &mi386) {		x86_thread_state32_t regs;		n = x86_THREAD_STATE32_COUNT;		if(me(thread_get_state(t->thread, x86_THREAD_STATE32,				(thread_state_t)&regs,				&n)) < 0)			return -1;		if(singlestep)			regs.eflags |= FLAGS_TF;		else			regs.eflags &= ~FLAGS_TF;		if(me(thread_set_state(t->thread, x86_THREAD_STATE32,				(thread_state_t)&regs,				x86_THREAD_STATE32_COUNT)) < 0)			return -1;	} else {		x86_thread_state64_t regs;		n = x86_THREAD_STATE64_COUNT;		if(me(thread_get_state(t->thread, x86_THREAD_STATE64,				(thread_state_t)&regs,				&n)) < 0)			return -1;		if(singlestep)			regs.rflags |= FLAGS_TF;		else			regs.rflags &= ~FLAGS_TF;		if(me(thread_set_state(t->thread, x86_THREAD_STATE64,				(thread_state_t)&regs,				x86_THREAD_STATE64_COUNT)) < 0)			return -1;	}	// Run.	n = sizeof info;	if(me(thread_info(t->thread, THREAD_BASIC_INFO, (thread_info_t)&info, &n)) < 0)		return -1;	for(i=0; i<info.suspend_count; i++)		if(me(thread_resume(t->thread)) < 0)			return -1;	return 0;}
开发者ID:8l,项目名称:go-learn,代码行数:54,


示例27: threadstopped

// Is thread t suspended?static intthreadstopped(Thread *t){	struct thread_basic_info info;	uint size;	size = sizeof info;	if(me(thread_info(t->thread, THREAD_BASIC_INFO, (thread_info_t)&info, &size)) <  0){		fprint(2, "threadstopped thread_info %#x: %r/n");		return 1;	}	return info.suspend_count > 0;}
开发者ID:8l,项目名称:go-learn,代码行数:14,


示例28: thread_reed_partitions_merge

static bool thread_reed_partitions_merge(protocol_interface_info_entry_t *cur, uint16_t shortAddress, thread_leader_data_t heard_partition_leader_data){    if (thread_is_router_addr(shortAddress)) {        return false;    }    if (thread_extension_version_check(thread_info(cur)->version)) {        // lower weighting heard        if (thread_info(cur)->thread_leader_data->weighting > heard_partition_leader_data.weighting) {            return false;        }        // lower/same partition id heard        if (thread_info(cur)->thread_leader_data->weighting == heard_partition_leader_data.weighting &&                thread_info(cur)->thread_leader_data->partitionId >= heard_partition_leader_data.partitionId ) {            return false;        }    } else if (thread_info(cur)->thread_leader_data->partitionId >= heard_partition_leader_data.partitionId){        return false;    }    // can merge to a higher weighting/partition id    thread_bootstrap_connection_error(cur->id, CON_ERROR_PARTITION_MERGE, NULL);    return true;}
开发者ID:OpenNuvoton,项目名称:mbed,代码行数:22,



注:本文中的thread_info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ thread_lock函数代码示例
C++ thread_id函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。