Beispiel #1
0
/**
 * krbtree_modulate_prio()
 * modulate/perturb the priority of the current thread
 * by some random amount. It might be useful to convert
 * some processes to RT priority as well. 
 */
int krbtree_modulate_prio(void){
   struct sched_param prio;
   unsigned int randval;
   if(modulate_priority){
     randval = get_osa_random()%50;
     if(randval > 40){
       /* turn the thread into a real time process */
       prio.sched_priority = SCHED_RR;
       sys_sched_setscheduler(0,(randval*11)%99,&prio);
       return 0;
     }
     
     /* just change the process priority, leaving
      * it with it's current scheduler. */
     randval -= 20;
     sys_setpriority(PRIO_PROCESS,0,randval);
     return 0;
   }
   
   // Don't modulate priority
   /* turn the thread into a real time process at highest priority*/
   prio.sched_priority = SCHED_RR;
   sys_sched_setscheduler(0,99,&prio);
   return 0;
}
Beispiel #2
0
static void restore_sched_info(struct rst_sched_param *p)
{
	struct sched_param parm;

	pr_info("Restoring scheduler params %d.%d.%d\n",
			p->policy, p->nice, p->prio);

	sys_setpriority(PRIO_PROCESS, 0, p->nice);
	parm.sched_priority = p->prio;
	sys_sched_setscheduler(0, p->policy, &parm);
}
Beispiel #3
0
/* Create a RR real-time task with the specified callback and priority. */
void linsched_create_RTrr_task(void (*callback)(void), int prio)
{
	struct sched_param params;

	/* If we cannot support any more tasks, return. */
	if (curr_task_id >= LINSCHED_MAX_TASKS)
		return;

	/* Create RR real-time task and set its priority. */
	__linsched_tasks[curr_task_id] = __linsched_create_task(callback);
	params.sched_priority = prio;
	sys_sched_setscheduler(__linsched_tasks[curr_task_id], SCHED_RR,
			       &params);

        /* Print message. */
	printf("Created RR real-time task 0x%x with priority %d.\n",
	       (unsigned int)__linsched_tasks[curr_task_id], prio);

	/* Increment task id. */
	curr_task_id++;
}
Beispiel #4
0
/* Create a batch task with the specified callback and 
 * nice value of niceval, which determines its priority.
 */
void linsched_create_batch_task(void (*callback)(void), int niceval)
{
	struct sched_param params;

	/* If we cannot support any more tasks, return. */
	if (curr_task_id >= LINSCHED_MAX_TASKS)
		return;

	/* Create "batch" task and set its nice value. */
	__linsched_tasks[curr_task_id] = __linsched_create_task(callback);
	params.sched_priority = 0;
	sys_sched_setscheduler(__linsched_tasks[curr_task_id], SCHED_BATCH,
			       &params);
	set_user_nice(__linsched_tasks[curr_task_id], niceval);

	/* Print message. */
	printf("Created batch task 0x%x with nice value %d.\n",
	       (unsigned int)__linsched_tasks[curr_task_id], niceval);

	/* Increment task id. */
	curr_task_id++;
}
Beispiel #5
0
/* NEW VERSION
 */
void linsched_create_normal_task_binary(struct elf_binary* binary, int niceval)
{
        struct sched_param params;
        unsigned long long time_slice;
        int query[3];
	
	query[0] = binary->size;
	query[1] = binary->bss;
	query[2] = binary->input_size; 
	/* If we cannot support any more tasks, return. */
        if (curr_task_id >= LINSCHED_MAX_TASKS)
                return;
	time_start = sched_clock();
		
	sim_param = (query[0]+query[1]+query[2])/(30*2);	
	time_slice = knn(&query[0], 3);
	time_slice *= 1000000;
	//time_slice = 500000000;
        /* Create "normal" task and set its nice value. */
        __linsched_tasks[curr_task_id] = __linsched_create_task_binary(binary->callback, time_slice);
        params.sched_priority = 0;
        


	sys_sched_setscheduler(__linsched_tasks[curr_task_id], SCHED_NORMAL,
                               &params);
        set_user_nice(__linsched_tasks[curr_task_id], niceval);

        /* Print message. */
        printf("Created normal task 0x%x with nice value %d.\n",
               (unsigned int)__linsched_tasks[curr_task_id], niceval);

        /* Increment task id. */
        curr_task_id++;



}
/* Note: it is necessary to treat pid and policy as unsigned ints,
 * with the corresponding cast to a signed int to insure that the 
 * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
 * and the register representation of a signed int (msr in 64-bit mode) is performed.
 */
asmlinkage long compat_sys_sched_setscheduler(u32 pid, u32 policy, struct sched_param __user *param)
{
	return sys_sched_setscheduler((int)pid, (int)policy, param);
}
static void autok_thread_func(struct work_struct *data)
#endif  // USE_KERNEL_THREAD
{
    int err = 0;
    
    #ifdef USE_KERNEL_THREAD
    struct sdio_autok_thread_data *autok_thread_data = (struct sdio_autok_thread_data *)data;
    #else   // USE_KERNEL_THREAD
    struct sdio_autok_workqueue_data *autok_thread_data = (struct sdio_autok_workqueue_data *)data;
    #endif  // USE_KERNEL_THREAD
    
    struct msdc_host *host = autok_thread_data->host;
    char stage = autok_thread_data->stage;
    char *envp[2];
    char *lteprocenvp[2];
#ifdef CHANGE_SCHED_POLICY    
    struct sched_param param;
    int sched_policy;
    
    #ifdef SCHED_POLICY_INFO
    sched_policy = sys_sched_getscheduler(0);
    printk("[%s] orig. sched policy: %d\n", __func__, sched_policy);
    
    param.sched_priority = sys_sched_get_priority_max(SCHED_FIFO);
    if( sys_sched_setscheduler( 0, SCHED_FIFO, &param ) == -1 )
    {
    	printk("[%s] sched_setscheduler fail\n", __func__);
    }
    
    sched_policy = sys_sched_getscheduler(0);
    printk("[%s] sched policy FIFO: %d\n", __func__, sched_policy);
    #endif
    
    //param.sched_priority = sched_get_priority_max(SCHED_RR);
    param.sched_priority = 1;
    if( sys_sched_setscheduler( 0, SCHED_RR, &param ) == -1 )
    {
    	printk("[%s] sched_setscheduler fail\n", __func__);
    }
    
    #ifdef SCHED_POLICY_INFO
    sched_policy = sys_sched_getscheduler(0);
    printk("[%s] modified sched policy: %d\n", __func__, sched_policy);
    #endif
#endif    
    if(stage == 1) {
        // call stage 1 auto-K callback function
        msdc_autok_stg1_cal(host);
        
        envp[0] = "FROM=sdio_autok";
        envp[1] = NULL;
        err = kobject_uevent_env(&host->mmc->class_dev.kobj, KOBJ_ONLINE, envp);
        if(err < 0)
            printk(KERN_INFO "[%s] kobject_uevent_env error = %d\n", __func__, err);
    } else if(stage == 2) {
        // call stage 2 auto-K callback function
        msdc_autok_stg2_cal(host, autok_thread_data->autok_stage1_result, autok_thread_data->len);
    } else {
        printk(KERN_INFO "[%s] stage %d doesn't support in auto-K\n", __func__, stage);
#ifdef USE_KERNEL_THREAD
        return -EFAULT;
#else   // USE_KERNEL_THREAD
        return;
#endif  // USE_KERNEL_THREAD
    }
    
    lteprocenvp[0] = "FROM=autok_done";
    lteprocenvp[1] = NULL;
    err = kobject_uevent_env(&host->mmc->class_dev.kobj, KOBJ_ONLINE, lteprocenvp);
    if(err < 0)
        printk(KERN_INFO "[%s] kobject_uevent_env error = %d\n", __func__, err);
    
#ifdef USE_KERNEL_THREAD
    return 0;
#else   // USE_KERNEL_THREAD
    return;
#endif  // USE_KERNEL_THREAD
}