• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ sched_get_priority_min函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: controler

/* thread function 1 */
void * controler ( void * arg )
{
	int ret = 0;

	/* Wait until the policy has been changed. */
	ret = pthread_barrier_wait( arg );

	if ( ( ret != 0 ) && ( ret != PTHREAD_BARRIER_SERIAL_THREAD ) )
	{
		UNRESOLVED( ret, "barrier wait failed" );
	}

	/* check the thread attributes have been applied
	  (we only check what is reported, not the real behavior) 
	 */
	check_param( pthread_self(), SCHED_RR, sched_get_priority_min( SCHED_RR ) );

	return NULL;
}
开发者ID:8l,项目名称:rose,代码行数:20,代码来源:pthread_setschedparam.1-2.c


示例2: main

int main(int argc, char **argv)
{	       
	int result = -1;
	
	result = sched_get_priority_min(SCHED_SPORADIC);
	
	if(result != -1 && errno == 0 ) {
		printf("The minimum priority for policy SCHED_SPORADIC is %i.\n",
		       result);
		printf("Test PASSED\n");
		return PTS_PASS;
	} else {
		perror("An error occurs");
		return PTS_FAIL;
	}
		
	printf("This code should not be executed.\n");
        return PTS_UNRESOLVED;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:19,代码来源:1-3.c


示例3: sched_getscheduler

void Thread::setPriority(Priority _priority) {
	
#if ARX_HAVE_SCHED_GETSCHEDULER
	int policy = sched_getscheduler(0);
#else
	int policy = SCHED_RR;
#endif
	
	int min = sched_get_priority_min(policy);
	int max = sched_get_priority_max(policy);
	
	priority = min + ((_priority - Lowest) * (max - min) / (Highest - Lowest));
	
	if(started && min != max) {
		sched_param param;
		param.sched_priority = priority;
		pthread_setschedparam(thread, policy, &param);
	}
}
开发者ID:EstrangedGames,项目名称:ArxLibertatis,代码行数:19,代码来源:Thread.cpp


示例4: ltos_sparam

static int
ltos_sparam(int policy, struct lx_sched_param *lsp, struct sched_param *sp)
{
	struct lx_sched_param ls;
	int smin = sched_get_priority_min(policy);
	int smax = sched_get_priority_max(policy);

	if (uucopy(lsp, &ls, sizeof (struct lx_sched_param)) != 0)
		return (-errno);

	bzero(sp, sizeof (struct sched_param));

	/*
	 * Linux has a fixed priority range, 0 - 99, which we need to convert to
	 * Solaris's dynamic range. Linux considers lower numbers to be
	 * higher priority, so we'll invert the priority within Solaris's range.
	 *
	 * The formula to convert between ranges is:
	 *
	 *	L * (smax - smin)
	 * S =  -----------------  + smin
	 *	  (lmax - lmin)
	 *
	 * where S is the Solaris equivalent of the linux priority L.
	 *
	 * To invert the priority, we use:
	 * S' = smax - S + smin
	 *
	 * Together, these two formulas become:
	 *
	 *		L * (smax - smin)
	 *   S = smax - -----------------  + 2smin
	 *			99
	 */
	sp->sched_priority = smax -
	    ((ls.lx_sched_prio * (smax - smin)) / LX_PRI_MAX) + 2*smin;

	lx_debug("ltos_sparam: linux prio %d = Solaris prio %d "
	    "(Solaris range %d,%d)\n", ls.lx_sched_prio, sp->sched_priority,
	    smin, smax);

	return (0);
}
开发者ID:maosi66,项目名称:illumos-joyent,代码行数:43,代码来源:sched.c


示例5: main

int main(int argc, char *argv[])
{
	int pri_boost, numcpus;
	setup();

	pass_criteria = CHECK_LIMIT;
	rt_init("hin:", parse_args, argc, argv);

	numcpus = sysconf(_SC_NPROCESSORS_ONLN);

	/* Max no. of busy threads should always be less than/equal the no. of cpus
	   Otherwise, the box will hang */

	if (rt_threads == -1 || rt_threads > numcpus) {
		rt_threads = numcpus;
		printf("Maximum busy thread count(%d), "
		       "should not exceed number of cpus(%d)\n", rt_threads,
		       numcpus);
		printf("Using %d\n", numcpus);
	}

	/* Test boilder plate: title and parameters */
	printf("\n-------------------\n");
	printf("Priority Preemption\n");
	printf("-------------------\n\n");
	printf("Busy Threads: %d\n", rt_threads);
	printf("Interrupter Threads: %s\n",
	       int_threads ? "Enabled" : "Disabled");
	printf("Worker Threads: %d\n\n", NUM_WORKERS);

	pri_boost = 81;
	create_fifo_thread(master_thread, (void *)0,
			   sched_get_priority_min(SCHED_FIFO) + pri_boost);

	/* wait for threads to complete */
	join_threads();

	printf
	    ("\nCriteria: All threads appropriately preempted within %d loop(s)\n",
	     (int)pass_criteria);
	printf("Result: %s\n", ret ? "FAIL" : "PASS");
	return ret;
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:43,代码来源:prio-preempt.c


示例6: sched_get_priority_min

//==============================================================================
JUCE_API void JUCE_CALLTYPE Process::setPriority (const ProcessPriority prior)
{
    const int policy = (prior <= NormalPriority) ? SCHED_OTHER : SCHED_RR;
    const int minp = sched_get_priority_min (policy);
    const int maxp = sched_get_priority_max (policy);

    struct sched_param param;

    switch (prior)
    {
        case LowPriority:
        case NormalPriority:    param.sched_priority = 0; break;
        case HighPriority:      param.sched_priority = minp + (maxp - minp) / 4; break;
        case RealtimePriority:  param.sched_priority = minp + (3 * (maxp - minp) / 4); break;
        default:                jassertfalse; break;
    }

    pthread_setschedparam (pthread_self(), policy, &param);
}
开发者ID:2DaT,项目名称:Obxd,代码行数:20,代码来源:juce_linux_Threads.cpp


示例7: main

int main(int argc, const char *argv[])
{
  int res;
  pthread_t a_thread;
  pthread_attr_t thread_attr;

  int max_priority;
  int min_priority;
  struct sched_param scheduling_value;

  res = pthread_attr_init(&thread_attr);
  if (res != 0) {
    perror("Attribute creation failed");
    exit(EXIT_FAILURE);
  }
  res = pthread_attr_setschedpolicy(&thread_attr, SCHED_OTHER);
  if (res != 0) {
    perror("Setting schedpolicy failed");
    exit(EXIT_FAILURE);
  }
  res = pthread_create(&a_thread, &thread_attr,
      thread_function, (void *)message);
  if (res != 0) {
    perror("Thread creation failed");
    exit(EXIT_FAILURE);
  }
  max_priority = sched_get_priority_max(SCHED_OTHER);
  min_priority = sched_get_priority_min(SCHED_OTHER);
  scheduling_value.sched_priority = min_priority;
  res = pthread_attr_setschedparam(&thread_attr, &scheduling_value);
  if (res != 0) {
    perror("Setting schedpolicy failed");
    exit(EXIT_FAILURE);
  }
  (void)pthread_attr_destroy(&thread_attr);
  while (!thread_finished) {
    printf("Waiting for thread to say it's finished...\n");
    sleep(1);
  }
  printf("Other thread finished, bye!\n");
  exit(EXIT_SUCCESS);
}
开发者ID:linq,项目名称:unix_learn,代码行数:42,代码来源:thread6.c


示例8: main

int
main()
{
  pthread_t t;
  void * result = NULL;
  int result2;
  struct sched_param param;

  assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1);
  assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1);

  assert(pthread_create(&t, NULL, getValidPriorities, NULL) == 0);
  assert(pthread_join(t, &result) == 0);

  assert(pthread_barrier_init(&startBarrier, NULL, 2) == 0);
  assert(pthread_barrier_init(&endBarrier, NULL, 2) == 0);

  /* Set the thread's priority to a known initial value.
   * If the new priority is invalid then the threads priority
   * is unchanged from the previous value.
   */
  SetThreadPriority(pthread_getw32threadhandle_np(pthread_self()),
                    PTW32TEST_THREAD_INIT_PRIO);

  for (param.sched_priority = minPrio;
       param.sched_priority <= maxPrio;
       param.sched_priority++)
    {
      assert(pthread_create(&t, NULL, func, NULL) == 0);
      assert(pthread_setschedparam(t, SCHED_OTHER, &param) == 0);
      result2 = pthread_barrier_wait(&startBarrier);
      assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD);
      result2 = pthread_barrier_wait(&endBarrier);
      assert(result2 == 0 || result2 == PTHREAD_BARRIER_SERIAL_THREAD);
      assert(GetThreadPriority(pthread_getw32threadhandle_np(t)) ==
	  validPriorities[param.sched_priority+(PTW32TEST_MAXPRIORITIES/2)]);
      pthread_join(t, &result);
      assert(param.sched_priority == (int)result);
    }

  return 0;
}
开发者ID:Schiiiiins,项目名称:lcu1,代码行数:42,代码来源:priority2.c


示例9: test_priority

void test_priority(const char *const name, const int policy)
{
    const pid_t         me = getpid();
    struct sched_param  param;

    param.sched_priority = sched_get_priority_max(policy);
    printf("sched_get_priority_max(%s) = %d\n", name, param.sched_priority);
    if (sched_setscheduler(me, policy, &param) == -1)
        printf("sched_setscheduler(getpid(), %s, { %d }): %s.\n", name, param.sched_priority, strerror(errno));
    else
        printf("sched_setscheduler(getpid(), %s, { %d }): Ok.\n", name, param.sched_priority);

    param.sched_priority = sched_get_priority_min(policy);
    printf("sched_get_priority_min(%s) = %d\n", name, param.sched_priority);
    if (sched_setscheduler(me, policy, &param) == -1)
        printf("sched_setscheduler(getpid(), %s, { %d }): %s.\n", name, param.sched_priority, strerror(errno));
    else
        printf("sched_setscheduler(getpid(), %s, { %d }): Ok.\n", name, param.sched_priority);

}
开发者ID:MarkTseng,项目名称:mySampleCode,代码行数:20,代码来源:thread_priv_test.c


示例10: sched_get_priority_min

/* thread function 2 */
void *changer(void *arg)
{
	int ret = 0;

	struct sched_param sp;
	sp.sched_priority = sched_get_priority_min(SCHED_RR);

	if (sp.sched_priority < 0) {
		UNTESTED("Failed to get min SCHED_RR range");
	}

	/* set the other thread's policy */
	ret = pthread_setschedparam(*(pthread_t *) arg, SCHED_RR, &sp);

	if (ret != 0) {
		UNRESOLVED(ret, "Failed to set other's thread policy");
	}

	return NULL;
}
开发者ID:1587,项目名称:ltp,代码行数:21,代码来源:1-2.c


示例11: PJ_DEF

/*
 * Get the lowest priority value available on this system.
 */
PJ_DEF(int) pj_thread_get_prio_min(pj_thread_t *thread)
{
    struct sched_param param;
    int policy;
    int rc;

    rc = pthread_getschedparam(thread->thread, &policy, &param);
    if (rc != 0)
	return -1;

#if defined(_POSIX_PRIORITY_SCHEDULING)
    return sched_get_priority_min(policy);
#elif defined __OpenBSD__
    /* Thread prio min/max are declared in OpenBSD private hdr */
    return 0;
#else
    pj_assert("pj_thread_get_prio_min() not supported!");
    return 0;
#endif
}
开发者ID:ChrisKwon,项目名称:spore,代码行数:23,代码来源:os_core_unix.c


示例12: task

static void task(rtems_task_argument arg)
{
  rtems_status_code sc;

  (void) arg;

  rtems_test_assert(rtems_get_current_processor() == 1);
  rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
  rtems_test_assert(sched_get_priority_max(SCHED_RR) == 126);

  sc = rtems_semaphore_obtain(sema_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
  rtems_test_assert(sc == RTEMS_NOT_DEFINED);

  sc = rtems_event_transient_send(main_task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  while (1) {
    /* Do nothing */
  }
}
开发者ID:greenmeent,项目名称:rtems,代码行数:20,代码来源:init.c


示例13: check_priority_range

    void uhd::set_thread_priority(float priority, bool realtime){
        check_priority_range(priority);

        //when realtime is not enabled, use sched other
        int policy = (realtime)? SCHED_RR : SCHED_OTHER;

        //we cannot have below normal priority, set to zero
        if (priority < 0) priority = 0;

        //get the priority bounds for the selected policy
        int min_pri = sched_get_priority_min(policy);
        int max_pri = sched_get_priority_max(policy);
        if (min_pri == -1 or max_pri == -1) throw uhd::os_error("error in sched_get_priority_min/max");

        //set the new priority and policy
        sched_param sp;
        sp.sched_priority = int(priority*(max_pri - min_pri)) + min_pri;
        int ret = pthread_setschedparam(pthread_self(), policy, &sp);
        if (ret != 0) throw uhd::os_error("error in pthread_setschedparam");
    }
开发者ID:sergforce,项目名称:UHD-Fairwaves,代码行数:20,代码来源:thread_priority.cpp


示例14: pthread_attr_init

void *child_thread(void *arg)
{
    int policy;
    int max_priority,min_priority;
    struct sched_param param;
    pthread_attr_t attr;

    pthread_attr_init(&attr);
    pthread_attr_setinheritsched(&attr,PTHREAD_EXPLICIT_SCHED);
    pthread_attr_getinheritsched(&attr,&policy);
    if(policy == PTHREAD_EXPLICIT_SCHED)
    {
        printf("inheritsched:PTHREAD_EXPLICIT_SCHED\n");
    }

    if(policy == PTHREAD_INHERIT_SCHED)
    {
        printf("Inheritsched:PTHREAD_INHERIT_SCHED\n");
    }
    pthread_attr_setschedpolicy(&attr,SCHED_RR);
    pthread_attr_getschedpolicy(&attr,&policy);
    if(policy ==SCHED_FIFO)
    {
        printf("schedpolicy: SCHED_FIFO\n");
    }
    if(policy == SCHED_RR)
        printf("schedpolicy: SCHED_RR\n");

    if(policy == SCHED_OTHER)
        printf("schedpolicy: SCHED_OTHER\n");

    sched_get_priority_max(max_priority);
    sched_get_priority_min(min_priority);
    printf("max priority: %u\n",max_priority);
    printf("min priority: %u\n",min_priority);

    param.sched_priority = max_priority;
    pthread_attr_setschedparam(&attr,&param);
    printf("sched_priority:%u\n",param.sched_priority);
    pthread_attr_destroy(&attr);
}
开发者ID:xxxhycl2010,项目名称:Learn-Linux,代码行数:41,代码来源:test_thread3.c


示例15: rtaudio_boost_priority

static PyObject *
rtaudio_boost_priority(PyObject *obj, PyObject *args)
{
#if defined(__LINUX_ALSA__) || defined(__LINUX_OSS__) || defined(__LINUX_JACK__)
  struct sched_param schp = { 0 };
  int priority = (sched_get_priority_max(SCHEDULER_POLICY) -
                  sched_get_priority_min(SCHEDULER_POLICY)) / 2;
  schp.sched_priority = priority;
  
  if (sched_setscheduler(0, SCHEDULER_POLICY, &schp) != 0)
    {
      PyErr_Format(RtAudioError, "insufficient priveledges");
      return NULL;
    }

  /* We are running at high priority so we should have a watchdog in
     case audio goes wild. */
#endif

#if defined(__MACOSX_CORE__)

  struct sched_param sp;
  memset(&sp, 0, sizeof(struct sched_param));
  int policy;

  if (pthread_getschedparam(pthread_self(), &policy, &sp) == -1)
    {
      PyErr_SetString(RtAudioError, strerror(errno));
      return NULL;
    }

  sp.sched_priority += 40;
  if (pthread_setschedparam(pthread_self(), SCHED_RR, &sp)  == -1) 
    {
      PyErr_SetString(RtAudioError, strerror(errno));
      return NULL;
    }

#endif
  Py_RETURN_NONE;
}
开发者ID:RikVerschueren,项目名称:AccordionMega,代码行数:41,代码来源:rtaudiomodule.cpp


示例16: defined

bool gcore::Thread::priority(gcore::Thread::Priority prio) {
  if (mRunning) {
    sched_param sched; // = {0, 0};
    int plcy = 0;
    if (pthread_getschedparam((pthread_t)mSelf, &plcy, &sched) == 0) {
#if defined(_POSIX_PRIORITY_SCHEDULING)
      int priomax = sched_get_priority_max(plcy);
      int priomin = sched_get_priority_min(plcy);
#elif defined(PTHREAD_MINPRIORITY) && defined(PTHREAD_MAX_PRIORITY)
      int priomin = PTHREAD_MIN_PRIORITY;
      int priomax = PTHREAD_MAX_PRIORITY;
#else
      int priomin = 0;
      int priomax = 32;
#endif
      int priomed = (priomax + priomin) / 2;
      switch (prio) {
      case PRI_VERY_LOW:
        sched.sched_priority = priomin;
        break;
      case PRI_LOW:
        sched.sched_priority = (priomin + priomed) / 2;
        break;
      case PRI_NORMAL:
        sched.sched_priority = priomed;
        break;
      case PRI_HIGH:
        sched.sched_priority = (priomax + priomed) / 2;
        break;
      case PRI_VERY_HIGH:
        sched.sched_priority = priomax;
        break;
      default:
        sched.sched_priority = priomed;
        break;
      }
      return (pthread_setschedparam((pthread_t)mSelf, plcy, &sched) == 0);
    }
  }
  return false;
}
开发者ID:gatgui,项目名称:gcore,代码行数:41,代码来源:threads.cpp


示例17: clEoQueueInitialize

/*
 * Setup the priority map
*/
ClRcT clEoQueueInitialize(void)
{
    ClInt32T minPriority = sched_get_priority_min(CL_EO_SCHED_POLICY);
    ClInt32T maxPriority = sched_get_priority_max(CL_EO_SCHED_POLICY);
    ClInt32T priority=maxPriority;
    ClInt32T decr = 10;
    ClRcT rc = CL_OK;
    register ClInt32T i;

    if(minPriority < 0 )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error getting minPriority\n"));
        minPriority = 0;
    }
    if(maxPriority < 0 )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error getting maxPriority\n"));
        maxPriority = 0;
    }

    if(!priority) decr = 0;

    for(i = CL_IOC_HIGH_PRIORITY; i <= CL_IOC_LOW_PRIORITY; ++i)
    {
        gClEoThreadPriorityMap[i] = CL_MAX(priority, 0);
        priority -= decr;
    }

    gClEoThreadPriorityMap[CL_IOC_DEFAULT_PRIORITY] = CL_MAX(priority, 0);
    for(i = CL_IOC_RESERVED_PRIORITY ; i < CL_IOC_MAX_PRIORITIES ; ++i)
        gClEoThreadPriorityMap[i] = CL_MAX(priority, 0);

    rc = clOsalMutexInit(&gClEoQueueMutex);
    CL_ASSERT(rc == CL_OK);

#if defined (EO_QUEUE_STATS)
    signal(SIGUSR2, sigusr2_handler);
#endif

    return rc;
}
开发者ID:NguyenHoangOC,项目名称:SAFplus-Availability-Scalability-Platform,代码行数:44,代码来源:clEoQueue.c


示例18: init_linux_scheduler

void init_linux_scheduler(int sched, int pri)
{
        struct sched_param mysched;

	if(sched != SCHED_RR && sched != SCHED_FIFO) {
                puts("Invalid scheduling scheme");
                exit(1);
	}

	if((pri < sched_get_priority_min(sched)) || (pri > sched_get_priority_max(sched))) {
		puts("Invalid priority");
		exit(2);
	}

        mysched.sched_priority = pri ;
        if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 ) {
                puts("Error in setting the Linux scheduler");
                perror("errno");
                exit(3);
        }
}
开发者ID:ArcEye,项目名称:rtai-1,代码行数:21,代码来源:init.c


示例19: memset

	/**
	 * @brief	Sets a new thread priority.
	 *
	 * @note 	Has no effect when USE_CPP11 is defined
	 *
	 * @param	iPriority	the new priority.
	 */
	void Thread::setPriority( EPriority iPriority )
	{
		m_iThreadPriority = iPriority;

#ifndef USE_CPP11
#	ifdef linux
		struct sched_param sp;
		memset(&sp, 0, sizeof(struct sched_param));
	
		int iMin = sched_get_priority_min(0);
		int iMax = sched_get_priority_max(0);
		int iAvg = (iMax + iMin) / 2;

		sp.sched_priority = iAvg + ( iPriority * (iMax - iMin) ) / 4;

		pthread_setschedparam(m_iThreadID, SCHED_RR, &sp);
#	else
		SetThreadPriority(&m_hThread, iPriority);
#	endif
#endif
	}
开发者ID:jaytea,项目名称:oocl,代码行数:28,代码来源:Thread.cpp


示例20: pthread_setcanceltype

void *thfn(void *arg)
{
   struct sched_param sp;

   (void) arg;

   // cancel me at anytime
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

   // go batch, min prio
   sched_getparam(0, &sp);
   sp.sched_priority = sched_get_priority_min(SCHED_BATCH);
   if (sched_setscheduler(0, SCHED_BATCH, &sp))
   {
      perror("setscheduler background");
   }

   while(1);

   return NULL;
}
开发者ID:rschoene,项目名称:ftalat,代码行数:21,代码来源:main.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sched_getaffinity函数代码示例发布时间:2022-05-30
下一篇:
C++ sched_fork函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap