Example SPAK code that tries to find a preemptive, non-preemptive, and preemption threshold schedule for a task set:
  struct task_set *ts;
  int feas;

  max_resp = 100000;

  ts = create_task_set (3, 0, 0, 3,
  "preemption_thresh_rtcsa_table1", 
  1000, 0, 0, 0,
  "Wang00_fixed");
  //                    C    T    D    J    B
  new_simple_task (ts, 20,  70,  50,   0,   0, "t1");
  new_simple_task (ts, 20,  80,  80,   0,   0, "t2");
  new_simple_task (ts, 35, 200, 100,   0,   0, "t3");

  set_priorities (ts, INORDER);

  make_all_preemptible (ts);
  assign_optimal_pri (ts);
  feas = feasible (ts, FALSE);
  if (feas == num_tasks (ts)) {
    printf ("found a fully preemptive schedule:\n");
    print_task_set (ts);
  } else {
    printf ("optimal preemptive algorithm did not find a schedule\n");
  }
  
  printf ("\n");

  make_all_nonpreemptible (ts);
  assign_optimal_pri (ts);
  feas = feasible (ts, FALSE);
  if (feas == num_tasks (ts)) {
    printf ("found a fully non-preemptive schedule:\n");
    print_task_set (ts);
  } else {
    printf ("optimal non-preemptive algorithm did not find a schedule\n");
  }

  printf ("\n");

  anneal_priorities_and_thresholds (&ts, TRUE);
  feas = feasible (ts, FALSE);
  if (feas == num_tasks (ts)) {
    printf ("found a schedule using preemption thresholds:\n");
    print_task_set (ts);
  } else {
    printf ("heuristic preemption threshold algorithm did not find a schedule\n");
  }



Back to the main SPAK page.