#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <sched.h>
#include "cbs.h"

extern char **environ;

int main(int argc, char *argv[])
{
  int i, pid;
  int points;
  struct sched_param sp;
  struct cbs_param cs;
  int res;

  if (argc < 4) {
    printf("Usage: %s Q T <command>\n", argv[0]);

    return -1;
  }
  
  sp.sched_size = sizeof(struct cbs_param);
  sp.sched_p = &cs;
  cs.signature = CBS_SIGNATURE;
  cs.max_budget = atoi(argv[1]);
  cs.period = atoi(argv[2]);

  pid = atoi(argv[3]);

  res = sched_setscheduler(pid, SCHED_CBS, &sp);
  if (res < 0) {
    perror("Error in setscheduler!");
    exit(-1);
  }

  return 0;
}
