示例#1
0
/**
 * Prepare the various peripherals for use
 */
void init(void) {
    InitialiseBoard(); // Prepare the board (this is basic IO stuff, and also CPU init stuff)
    timer_init(); // Prepare the systick timer
    serial_init(); // Prepare the serial port
    i2c_init();
    eeprom_init();
    jobs_init(); // Prepare the job controller
}
示例#2
0
文件: ep1.c 项目: DiJei/MAC0422-
int main(int argc, char *argv[]) {
    int x;
    int y = 0;
    int size = 0;
    char line[MAX_LINE];
    char *token;
    int id;
    pthread_attr_t attr;
    pthread_mutex_t *mutex;
    pthread_t threadID[MAX_THREADS];
    trace processTable[MAX_THREADS];
    struct arg_struct args;  
 
    /*Verifica entrada*/
    if (argc < 4) {
    	printf("USAGE: ./ep1 x(1 to 6) traceFile resultFile -d(optional)\n");
    	exit(0);
    }
    id = atoi(argv[1]);

    FILE *trace;
    if ((trace = fopen(argv[2],"r")) == NULL) {
       	printf("arquivo:%s nao encontrado\n",argv[2]);
        exit(0);
    }
	/*---------------*/
  /*Ler o arquivo trace e monta a tabela de processo*/
  for (x = 0; x < MAX_LINE; x++)
    	line[x] = 0;
  while (1) {
       if (fgets(line, 100, trace) == NULL)
          break;
       size++;
       getTokens(line, &processTable[size -1]);
  }
  /*---------------------------------------------------*/
  

  switch(id) {
    /*Escalanador first in first out*/
    case 1:
    /*Atributos inicias*/
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    /*Inicializa todos os jobs*/
    jobs_init(processTable,threadID, size, &attr);
    pthread_attr_destroy(&attr);
    break;
  }  
   
  return (0);
 
}
示例#3
0
static __init int counter_init(void)
{
	int ret;

	pr_info("Initializing concurrent counter module\n");

	ret = jobs_init();
	if (ret)
		return ret;

	return 0;
}
示例#4
0
文件: main.c 项目: raptium/coursework
int main(int argc, char *argv[], char *envp[]) {
  char line[256];
  char ch;
  char *pwd;
  int i;
  cmd_ptr *cmdptr = NULL;

  pwd = malloc(sizeof(char) * 1024);
  jlist = jobs_init();
  //signal(SIGCHLD, SIG_DFL);
  signal(SIGINT,  SIG_IGN);
  signal(SIGTERM, SIG_IGN);
  signal(SIGQUIT, SIG_IGN);
  signal(SIGTSTP, SIG_IGN);
  signal(SIGSTOP, SIG_IGN);


  for (;;) {
    struct task *newtask;
    struct tnode *nodelist;
    strcpy(pwd, getenv("PWD"));
    printf("[CSC3150 shell:%s]$", pwd);

    line[0] = 0;
    i = 0;
    while ((ch = getchar()) != '\n')
      line[i++] = ch;
    line[i] = 0;
    if (line[0] == 0)
      continue;
    //temp=malloc(sizeof(char)*(strlen(line)+1));
    //strcpy(temp,line);
    if (!firstck(line)) {
      printf("Error: invalid input command line\n");
      continue;
    }
    //printf("Error\n");
    cmdptr = malloc(sizeof(cmd_ptr));
    initialize2(cmdptr);
    newtask = malloc(sizeof(struct task));
    newtask->cmd = malloc(sizeof(char) * (strlen(line) + 1));
    strcpy(newtask->cmd, line);
    jlist->job[jlist->n++] = newtask;

    if (start_chk(line) == 2) {
      nodelist = bnode(line);
      exec1(nodelist);
      continue;
    }
    if (start_chk(line) == 3)
      getcmd3(line, cmdptr);
    else if (start_chk(line) == 4)
      getcmd4(line, cmdptr);
    else if (start_chk(line) == 5)
      getcmd5(line, cmdptr);
    else if (start_chk(line) == 6)
      getcmd6(line, cmdptr);
    else if (start_chk(line) == 7)
      getcmd7(line, cmdptr);
    else if (start_chk(line) == 8)
      getcmd8(line, cmdptr);

    else {
      printf("Error: invalid input command line\n");
      continue;
    }


    nodelist = newnode(cmdptr);
    newtask->tids = execute(nodelist, NULL, NULL);
    if (newtask->tids != NULL) {
      jlist->job[jlist->n] = newtask;
      jlist->n++;
    }
    lwait(newtask->tids);

  }


  return 0;
}