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

C++ sched_getparam函数代码示例

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

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



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

示例1: main

int main() {
	int old_priority;
	struct sched_param param;

	if (sched_getparam(0, &param) == -1) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}
	old_priority = param.sched_priority;

	param.sched_ss_max_repl = 0;
	param.sched_priority++;
	sched_setparam(0,&param);

	if (sched_getparam(0, &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	if (param.sched_priority == old_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	} else {
		printf("The priority have changed.\n");
		return PTS_FAIL;
	}

}
开发者ID:shubmit,项目名称:shub-ltp,代码行数:28,代码来源:23-4.c


示例2: main

int main()
{
	int old_priority;
	struct sched_param param;

	if (sched_getparam(0, &param) == -1) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}
	old_priority = param.sched_priority;

	/* set a sched_ss_repl_period lower than the sched_ss_init_budget */
	param.sched_ss_repl_period.tv_sec = 1;
	param.sched_ss_repl_period.tv_nsec = 0;

	param.sched_ss_init_budget.tv_sec = 2;
	param.sched_ss_init_budget.tv_nsec = 0;

	param.sched_priority++;
	sched_setparam(0, &param);

	if (sched_getparam(0, &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	if (param.sched_priority == old_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	} else {
		printf("The priority have changed.\n");
		return PTS_FAIL;
	}
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:34,代码来源:23-3.c


示例3: main

int main(void)
{
    int old_priority, old_policy, new_policy;
    struct sched_param param;
    int invalid_policy;
    char *label;
    pid_t pid = getpid();
    int rc;

    invalid_policy = INT_MAX;

    label = "sched_getparam()";
    rc = sched_getparam(pid, &param);
    if (rc)
        goto unresolved;
    old_priority = param.sched_priority;

    label = "sched_getscheduler()";
    rc = sched_getscheduler(pid);
    if (rc < 0)
        goto unresolved;
    old_policy = rc;

    label = "sched_setscheduler() - invalid policy succeeded?";
    rc = sched_setscheduler(0, invalid_policy, &param);
    if (!rc)
        goto unresolved;

    label = "sched_getparam()";
    rc = sched_getparam(pid, &param);
    if (rc)
        goto unresolved;

    label = "sched_getscheduler()";
    rc = sched_getscheduler(pid);
    if (rc < 0)
        goto unresolved;
    new_policy = rc;

    if (old_policy != new_policy) {
        printf("Failed: invalid policy change, old: %u, new %u\n",
               old_policy, new_policy);
        exit(PTS_FAIL);
    }

    if (old_priority != param.sched_priority) {
        printf("Failed: invalid priority change, old: %u, new %u\n",
               old_priority, param.sched_priority);
        exit(PTS_FAIL);
    }

    printf("Test PASSED\n");
    return PTS_PASS;

unresolved:
    ERR_MSG(label, rc);
    return PTS_UNRESOLVED;
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:58,代码来源:17-5.c


示例4: main

int main(){
	int old_priority, old_policy, new_policy;
	struct sched_param param;
	int invalid_policy;

	invalid_policy = 0;
	/* Linux does not treat minus value as invalid for policy */
	while(invalid_policy == SCHED_OTHER || 
		invalid_policy == SCHED_FIFO ||
		invalid_policy == SCHED_RR ||
		invalid_policy == SCHED_BATCH)
	invalid_policy++;

	if(sched_getparam(getpid(), &param) == -1) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}	
	old_priority = param.sched_priority;

	old_policy = sched_getscheduler(getpid());
	if(old_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	sched_setscheduler(0, invalid_policy, &param);

	if(errno == 0) {
		printf("No error occurs, could %i be a valid value for the scheduling policy ???\n", invalid_policy);
		return PTS_UNRESOLVED;
	}

	if(sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	new_policy = sched_getscheduler(getpid());
	if(new_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}
		

	if(old_policy == new_policy && 
	   old_priority == param.sched_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}
	
	if(param.sched_priority != old_priority) {
		printf("The param has changed\n");
	}
	if(new_policy != old_policy) {
		printf("The policy has changed\n");
	}
	return PTS_FAIL;
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:58,代码来源:17-5.c


示例5: main

int main(){
	int policy, result;
	int old_priority, old_policy, new_policy;
	struct sched_param param;

	if(sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}	
	old_priority = param.sched_priority;

	old_policy = sched_getscheduler(getpid());
	if(old_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	/* set a sched_ss_repl_period lower than the sched_ss_init_budget */
	param.sched_ss_repl_period.tv_sec = 1;
	param.sched_ss_repl_period.tv_nsec = 0;

	param.sched_ss_init_budget.tv_sec = 2;
	param.sched_ss_init_budget.tv_nsec = 0;
	
	param.sched_priority = sched_get_priority_max(SCHED_SPORADIC);

	result = sched_setscheduler(0, SCHED_SPORADIC, &param);
      
	if(sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	new_policy = sched_getscheduler(getpid());
	if(new_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}
		

	if(old_policy == new_policy && 
	   old_priority == param.sched_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}
	
	if(param.sched_priority != old_priority) {
		printf("The param has changed\n");
	}
	if(new_policy != old_policy) {
		printf("The policy has changed\n");
	}
	return PTS_FAIL;
	

}
开发者ID:crystax,项目名称:android-vendor-openpts,代码行数:56,代码来源:17-3.c


示例6: main

int main(void)
{
	int invalid_priority;
	int old_priority, old_policy, new_policy;
	struct sched_param param;

	if (sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}
	old_priority = param.sched_priority;

	old_policy = sched_getscheduler(getpid());
	if (old_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	invalid_priority = sched_get_priority_max(SCHED_SPORADIC);
	if (invalid_priority == -1) {
		perror("An error occurs when calling sched_get_priority_max()");
		return PTS_UNRESOLVED;
	}

	/* set an invalid priority */
	invalid_priority++;
	param.sched_ss_low_priority = invalid_priority;

	sched_setscheduler(0, SCHED_SPORADIC, &param);

	if (sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	new_policy = sched_getscheduler(getpid());
	if (new_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	if (old_policy == new_policy && old_priority == param.sched_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}

	if (param.sched_priority != old_priority) {
		printf("The param has changed\n");
	}
	if (new_policy != old_policy) {
		printf("The policy has changed\n");
	}
	return PTS_FAIL;

}
开发者ID:1587,项目名称:ltp,代码行数:55,代码来源:17-2.c


示例7: main

int main() {
	int max_priority, old_priority, old_policy, new_policy;
	struct sched_param param;

	if (sched_getparam(getpid(), &param) == -1) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}
	old_priority = param.sched_priority;

	old_policy = sched_getscheduler(getpid());
	if (old_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	/* Make sure that param.sched_priority != old_priority */
	max_priority = sched_get_priority_max(SCHED_SPORADIC);
	param.sched_priority = (old_priority == max_priority) ?
		sched_get_priority_min(SCHED_SPORADIC) :
		max_priority;

	param.sched_ss_max_repl = 0;

	sched_setscheduler(0, SCHED_SPORADIC, &param);

	if (sched_getparam(getpid(), &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	new_policy = sched_getscheduler(getpid());
	if (new_policy == -1) {
		perror("An error occurs when calling sched_getscheduler()");
		return PTS_UNRESOLVED;
	}

	if (old_policy == new_policy &&
	   old_priority == param.sched_priority) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}

	if (param.sched_priority != old_priority) {
		printf("The param has changed\n");
		return PTS_FAIL;
	}
	if (new_policy != old_policy) {
		printf("The policy has changed\n");
		return PTS_FAIL;
	}

}
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:53,代码来源:17-4.c


示例8: setRealTimeScheduling

/*------------------------------------------------------------------------------
 *  Set POSIX real-time scheduling
 *----------------------------------------------------------------------------*/
void
DarkIce :: setRealTimeScheduling ( void )               throw ( Exception )
{
// Only if the OS has the POSIX real-time scheduling functions implemented.
#if defined( HAVE_SCHED_GETSCHEDULER ) && defined( HAVE_SCHED_GETPARAM )
    int                 high_priority;
    struct sched_param  param;

    /* store the old scheduling parameters */
    if ( (origSchedPolicy = sched_getscheduler(0)) == -1 ) {
        throw Exception( __FILE__, __LINE__, "sched_getscheduler", errno);
    }

    if ( sched_getparam( 0, &param) == -1 ) {
        throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
    }
    origSchedPriority = param.sched_priority;
    
    /* set SCHED_FIFO with max - 1 priority or user configured value */
    if ( (high_priority = sched_get_priority_max(SCHED_FIFO)) == -1 ) {
        throw Exception(__FILE__,__LINE__,"sched_get_priority_max",errno);
    }
    reportEvent( 8, "scheduler high priority", high_priority);

    if (realTimeSchedPriority > high_priority) {
        param.sched_priority = high_priority - 1;
    } else {
        param.sched_priority = realTimeSchedPriority;
    }

    if ( sched_setscheduler( 0, SCHED_FIFO, &param) == -1 ) {
        reportEvent( 1,
                     "Could not set POSIX real-time scheduling, "
                     "this may cause recording skips.\n"
                     "Try to run darkice as the super-user.");
    } else {
        /* ask the new priortiy and report it */
        if ( sched_getparam( 0, &param) == -1 ) {
            throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
        }

        reportEvent( 1,
                     "Using POSIX real-time scheduling, priority",
                     param.sched_priority );
    }
#else
    reportEvent( 1, "POSIX scheduling not supported on this system, "
                    "this may cause recording skips");
#endif // HAVE_SCHED_GETSCHEDULER && HAVE_SCHED_GETPARAM
}
开发者ID:TinyGame,项目名称:raspbaby,代码行数:53,代码来源:DarkIce.cpp


示例9: setRealTimeScheduling

/*------------------------------------------------------------------------------
 *  Set POSIX real-time scheduling, if super-user
 *----------------------------------------------------------------------------*/
void
DarkIce :: setRealTimeScheduling ( void )               throw ( Exception )
{
    uid_t   euid;

    euid = geteuid();

    if ( euid == 0 ) {
        int                 high_priority;
        struct sched_param  param;

        /* store the old scheduling parameters */
        if ( (origSchedPolicy = sched_getscheduler(0)) == -1 ) {
            throw Exception( __FILE__, __LINE__, "sched_getscheduler", errno);
        }

        if ( sched_getparam( 0, &param) == -1 ) {
            throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
        }
        origSchedPriority = param.sched_priority;
        
        /* set SCHED_FIFO with max - 1 priority */
        if ( (high_priority = sched_get_priority_max(SCHED_FIFO)) == -1 ) {
            throw Exception(__FILE__,__LINE__,"sched_get_priority_max",errno);
        }
        reportEvent( 8, "scheduler high priority", high_priority);

        param.sched_priority = high_priority - 1;

        if ( sched_setscheduler( 0, SCHED_FIFO, &param) == -1 ) {
            throw Exception( __FILE__, __LINE__, "sched_setscheduler", errno);
        }

        /* ask the new priortiy and report it */
        if ( sched_getparam( 0, &param) == -1 ) {
            throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
        }

        reportEvent( 1,
                     "Using POSIX real-time scheduling, priority",
                     param.sched_priority );
    } else {
        reportEvent( 1,
        "Not running as super-user, unable to use POSIX real-time scheduling" );
        reportEvent( 1,
        "It is recommended that you run this program as super-user");
    }
}
开发者ID:bryangrim,项目名称:darkice,代码行数:51,代码来源:DarkIce.cpp


示例10: main

int main(int argc, char **argv)
{

	struct sched_param param;
	int result = -1;

	param.sched_priority = -1;

	result = sched_getparam(0, &param);

	if (result == 0 && param.sched_priority != -1 && errno == 0) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}

	if (errno != 0) {
		perror("Unexpected error");
		return PTS_FAIL;
	}

	if (result != 0) {
		printf("returned code is not zero.\n");
		return PTS_FAIL;
	} else {
		perror("Unresolved test error");
		return PTS_UNRESOLVED;
	}

	printf("This code should not be executed.\n");
	return PTS_UNRESOLVED;
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:31,代码来源:3-1.c


示例11: go_realtime

int go_realtime(void)
{
	int max_pri;
	struct sched_param sp;

	if (sched_getparam(0, &sp)) {
		perror("sched_getparam");
		return -1;
	}

	max_pri = sched_get_priority_max(SCHED_FIFO);
	sp.sched_priority = REALTIME_PRIORITY;

	if (sp.sched_priority > max_pri) {
		fprintf(stderr, "Invalid priority (maximum %d)\n", max_pri);
		return -1;
	}

	if (sched_setscheduler(0, SCHED_FIFO, &sp)) {
		perror("sched_setscheduler");
		return -1;
	}

	return 0;
}
开发者ID:RadioRevolt,项目名称:btrx,代码行数:25,代码来源:sched.c


示例12: main

int
main(int argc, char *argv[])
{
    int j, pol;
    struct sched_param sp;

    for (j = 1; j < argc; j++) {
        pol = sched_getscheduler(getLong(argv[j], 0, "pid"));
        if (pol == -1)
            errExit("sched_getscheduler");

        if (sched_getparam(getLong(argv[j], 0, "pid"), &sp) == -1)
            errExit("sched_getparam");

        printf("%s: %-5s ", argv[j],
                (pol == SCHED_OTHER) ? "OTHER" :
                (pol == SCHED_RR) ? "RR" :
                (pol == SCHED_FIFO) ? "FIFO" :
#ifdef SCHED_BATCH              /* Linux-specific */
                (pol == SCHED_BATCH) ? "BATCH" :
#endif
#ifdef SCHED_IDLE               /* Linux-specific */
                (pol == SCHED_IDLE) ? "IDLE" :
#endif
                "???");
        printf("%2d\n", sp.sched_priority);
    }

    exit(EXIT_SUCCESS);
}
开发者ID:duxing2007,项目名称:books-examples,代码行数:30,代码来源:sched_view.c


示例13: main

int main(){
	int result;
        struct sched_param param;

        /* We assume process Number 1 is created by root */
        /* and can only be accessed by root */ 
        /* This test should be run under standard user permissions */
        if (getuid() == 0) {
	  	if (set_nonroot() != 0) {
			  printf("Cannot run this test as non-root user\n");	
                return PTS_UNTESTED;
        }
        }

	if(sched_getparam(0, &param) == -1) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	result = sched_setparam(1, &param);

	if(result == -1 && errno == EPERM) {
		printf("Test PASSED\n");
		return PTS_PASS;
	} else if(errno != EPERM) {
	        perror("errno is not EPERM");
		return PTS_FAIL;
	} else {
		printf("The returned code is not -1.\n");
		return PTS_FAIL;
	}
}
开发者ID:ystk,项目名称:debian-ltp,代码行数:32,代码来源:26-1.c


示例14: main

int main()
{
	int policy, result;
	struct sched_param param;

	if (sched_getparam(0, &param) != 0) {
		perror("An error occurs when calling sched_getparam()");
		return PTS_UNRESOLVED;
	}

	/* set a sched_ss_repl_period lower than the sched_ss_init_budget */
	param.sched_ss_repl_period.tv_sec = 1;
	param.sched_ss_repl_period.tv_nsec = 0;

	param.sched_ss_init_budget.tv_sec = 2;
	param.sched_ss_init_budget.tv_nsec = 0;

	param.sched_priority = sched_get_priority_max(SCHED_SPORADIC);

	result = sched_setscheduler(0, SCHED_SPORADIC, &param);

	if (result == -1 && errno == EINVAL) {
		printf("Test PASSED\n");
		return PTS_PASS;
	} else if (result != -1) {
		printf("The returned code is not -1.\n");
		return PTS_FAIL;
	} else if (errno == EPERM) {
		printf
		    ("This process does not have the permission to set its own scheduling policy.\nTry to launch this test as root.\n");
		return PTS_UNRESOLVED;
	}
	perror("Unknow error");
	return PTS_FAIL;
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:35,代码来源:19-3.c


示例15: raise_priority

static int raise_priority()
{
    int max_pri;
    struct sched_param sp;

    fprintf(stderr, "Setting scheduler priority...\n");

    if (sched_getparam(0, &sp)) {
        perror("sched_getparam");
        return -1;
    }

    max_pri = sched_get_priority_max(SCHED_FIFO);
    sp.sched_priority = REALTIME_PRIORITY;

    if (sp.sched_priority > max_pri) {
        fprintf(stderr, "Invalid scheduling priority (maximum %d).\n", max_pri);
        return -1;
    }

    if (sched_setscheduler(0, SCHED_FIFO, &sp)) {
        perror("sched_setscheduler");
        fprintf(stderr, "Failed to set scheduler. Run as root otherwise you "
                "may get wow and skips!\n");
    }

    return 0;
}
开发者ID:doublerebel,项目名称:s-xwax,代码行数:28,代码来源:realtime.c


示例16: main

int main(int argc, char **argv)
{

	struct sched_param param;
	int result = -1;

	/* We assume process Number 1 is created by root */
	/* and can only be accessed by root */
	/* This test should be run under standard user permissions */
	if (geteuid() == 0) {
                if (set_nonroot() != 0) {
			printf("Cannot run this test as non-root user\n");
			return PTS_UNTESTED;
		}
	}

	result = sched_getparam(1, &param);

	if (result == -1 && errno == EPERM) {
		printf("Test PASSED\n");
		return PTS_PASS;
	}
	if (result == 0) {
		printf("The function sched_getparam has successed.\n");
		return PTS_FAIL;
	}
	if (errno != EPERM) {
		perror("errno is not EPERM: The system allows a non-root"
			"user to use sched_getparam()");
		return PTS_UNRESOLVED;
	} else {
		perror("Unresolved test error");
		return PTS_UNRESOLVED;
	}
}
开发者ID:barajas,项目名称:Intel-GLTP,代码行数:35,代码来源:6-1.c


示例17: posix_spawnattr_init

int posix_spawnattr_init(posix_spawnattr_t *attr)
{
  struct sched_param param;
  int ret;

  DEBUGASSERT(attr);

  /* Flags: None */

  attr->flags = 0;

  /* Set the default priority to the same priority as this task */

  ret = sched_getparam(0, &param);
  if (ret < 0)
    {
      return errno;
    }

  attr->priority = param.sched_priority;

  /* Set the default scheduler policy to the policy of this task */

  attr->policy = sched_getscheduler(0);

  /* Empty signal masek */

  attr->sigmask = 0;

  /* Default stack size */

  attr->stacksize = TASK_SPAWN_DEFAULT_STACKSIZE;
  return OK;
}
开发者ID:nsrango,项目名称:Firmware,代码行数:34,代码来源:lib_psa_init.c


示例18: osa_t_init

/******************************************************************************
 *  Initialize Portable layer Thread functions
 *
 *  Parameter:
 *      NONE
 *  Return value:
 *      0                   successful
 *****************************************************************************/
OSA_RESULT  osa_t_init(void)
{
    struct sched_param  sparam;
    pid_t               mypid;

    d3(printf("osa_t_init:\n"));
    
    /* setup thread handle list */
    g_ThreadList = (ThreadHandle_t*) malloc( sizeof(ThreadHandle_t) );
    memset(g_ThreadList, 0, sizeof(ThreadHandle_t));
    INIT_LIST_HEAD( &(g_ThreadList->list) );
    g_ThreadList->id = 0;
    g_ThreadList->magic = OSA_T_MAGIC;

    /* create, set tid tsd */
    if( _osa_tid_key == -1 )
        _osa_tsd_create(&_osa_tid_key);
    _osa_tsd_set( &_osa_tid_key, (size_t) g_ThreadList);

    /* set my schedule policy ?*/
    #if 1
    mypid = getpid();
    sched_getparam(mypid,&sparam);
    sparam.sched_priority = (OSA_T_LNX_PRIORITY_MAX - OSA_T_LNX_PRIORITY_MIN + 1)/2;
    sched_setscheduler(mypid, SCHED_RR, &sparam);
    //sched_setscheduler(mypid,SCHED_OTHER,&sparam);
    #endif

    // setup thread signal actions
    _osa_t_setup_signal();

    d3(printf("osa_t_init: end\n"));
    
    return 0;
}
开发者ID:OpenGelo,项目名称:Map2DFusion,代码行数:43,代码来源:osa_thread_linux.cpp


示例19: print_prio

void print_prio(pid_t pid)
{
    int sched;
    struct sched_param sp;

    printf("pid %d's priority: %d\n", pid, getpriority(PRIO_PROCESS, pid));

    printf("scheduling class: ");
    sched = sched_getscheduler(pid);
    switch (sched) {
    case SCHED_FIFO:
        printf("FIFO\n");
        break;
    case SCHED_RR:
        printf("RR\n");
        break;
    case SCHED_OTHER:
        printf("Normal\n");
        break;
    case -1:
        perror("sched_getscheduler");
        break;
    default:
        printf("Unknown\n");
    }

    sched_getparam(pid, &sp);
    printf("RT prio: %d (of %d to %d)\n", sp.sched_priority,
           sched_get_priority_min(sched), sched_get_priority_max(sched));
}
开发者ID:0omega,项目名称:platform_system_core,代码行数:30,代码来源:renice.c


示例20: spi_dev_channel_init

int spi_dev_channel_init( comm_channel_t *channel, char *interface, int baudrate )
{
    spi_connection_t *sc = spi_get_connection( channel );

    if (!sc) {
        return( -1 );
    }

	sc->fd = open(interface, O_RDWR);
	if (sc->fd == -1) {
		perror("open robostix dev");
		return -1;
	}

	struct sched_param param;
	pthread_attr_t attr;
	pthread_attr_init(&attr);
	sched_getparam(0, &param);
	if (param.sched_priority > 0) {
		/* javiator connection got a higher priority than the controller */
		param.sched_priority++;
		pthread_attr_setschedparam(&attr, &param);
		pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
		pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
	}
	pthread_create(&sc->thread, &attr, spi_thread, sc);
    return( 0 );
}
开发者ID:cksystemsgroup,项目名称:JNavigator,代码行数:28,代码来源:spi_dev_channel.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sched_getscheduler函数代码示例发布时间:2022-05-30
下一篇:
C++ sched_getcpu函数代码示例发布时间: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