Exemple #1
0
int sys_link()
{
    char *old_path, *new_path;
    if(argptr(0, &old_path, 1) < 0 || argptr(1, &new_path, 1) < 0)
        return -1;
    return ilink(old_path, new_path);
}
Exemple #2
0
//Create a new thread
int
sys_thread_create(void)
{
	char* tmain, *stack, *arg;

	if (argptr(0, &tmain, 1) < 0 || argptr(1, &stack, 1) < 0 || argptr(2, &arg, 1) < 0)
		return -1;

	return thread_create((void*)tmain, (void*)stack, (void*)arg);
}
Exemple #3
0
int
sys_waitstat(void)
{
  int *turnaround;
  int *runningtime;
  int n;
  if(argptr(0, &turnaround,n) < 0)
    return -1;
  if(argptr(1, &runningtime,n) < 0)
    return -1;
  return waitstat(turnaround, runningtime);
}
Exemple #4
0
int sys_t_sleep(void)
{
  void *chan, *p_lk;
  if(argptr(0, (void *)&chan, sizeof(void *)) < 0) {
    return -1;
  }
  if(argptr(1, (void *)&p_lk, sizeof(void *)) < 0) {
    return -1;
  }

  t_sleep(chan, (lock_t*)p_lk);
  return 0;
}
Exemple #5
0
int
sys_waitpid(void)
{
	int pid;
	argptr(0,(char**) &pid, 4); //Read PID variable from stack 4 bytes = int
	int *status;
	argptr(1,(char**) &status, 4); //Get reference to Status 
	int options;
	argptr(2, (char**) &options, 4);

	return waitpid(pid, status, options);

	//int stuff;
	//return waitpid(0, &stuff, 0);
}
Exemple #6
0
int sys_clone(void){
	void* fcn;
	void* arg;
	void* stack;
	if(argptr(0, (void*)&fcn, sizeof(void *)) < 0){
		return -1;
	}
	if(argptr(1, (void*)&arg, sizeof(void *)) < 0){
		return -1;
	}
	if(argptr(2, (void*)&stack, sizeof(void *)) < 0){
		return -1;
	}
	return clone(fcn, arg, stack);
}
Exemple #7
0
int sys_csleep(void)
{
	void *chan;
	lock_t *lk;
	if (argptr(0, (void*)&chan, sizeof(chan)) < 0)
	{
		return -1;
	}
	if (argptr(1, (void*)&lk, sizeof(lk)) < 0)
	{
		return -1;
	}
	csleep(chan, lk);
	return 0;
}
Exemple #8
0
/********************STUDENT********************/
int
sys_wait2(void)
{
	int *w, *r;
	int m, n;
	
	
	n = argptr(0, (void *) &w, sizeof(*w));
	m = argptr(1, (void *) &r, sizeof(*r));
	
	
	if (m < 0 || n < 0)
		return -1;
  return wait2(w, r);
}
int
sys_clone(void)
{
  void (*fcn)(void*);
  void* arg;
  void* stack;
  if(argptr(0, (void*)&fcn, sizeof(void*)) < 0)
    return -1;
  if(argptr(1, (void*)&arg, sizeof(void*)) < 0)
    return -1;
  if(argptr(2, (void*)&stack, sizeof(void*)) < 0)
    return -1;
  
  
  return clone(fcn, arg, stack);
}
Exemple #10
0
int sys_unlink()
{
    char *path;
    if(argptr(0, &path, 1) < 0)
        return -1;
    return iunlink(path);
}
Exemple #11
0
int sys_checkpoint(void)
{
	char *p = 0;
	if (argptr(0, &p, sizeof(struct proc)) < 0)
		return -1;
	return checkpoint((struct proc *) p);
}
Exemple #12
0
int
sys_wait(void)
{
  int *status;
  argptr(0, (char **) &status, sizeof(int*));
  return wait(status);
}
Exemple #13
0
// thread library
int
sys_clone(void)
{
  void * ptr;
  argptr(0, (char **) &ptr, sizeof(void*));
  return clone(ptr);
}
Exemple #14
0
long
sys_write(SyscallFrame *f)
{
    int fd;
    long l;
    uintptr buf;
    usize nbytes;
    File *file;

    // fd
    if (argfd(f, 0, &fd) < 0)
        return -1;

    // nbytes (needed for argptr)
    if (arglong(f, 2, &l) < 0) {
        // todo errstr
        return -1;
    }
    nbytes = (usize)l;

    // buf
    if (argptr(f, 1, &buf, nbytes) < 0) {
        // todo errstr
        return -1;
    }

    file = proc->files[fd];

    if (!(file->omode &(OWRITE | ORDWR))) {
        // todo errstr
        return -1;
    }

    return file->write(file, (char *)buf, nbytes);
}
Exemple #15
0
int
clone(void)
{
  char* stack;
  int i, pid, size;
  struct proc *np;
  cprintf("a\n");
  // Allocate process.
  if((np = allocproc()) == 0)
    return -1;

  // Point page dir at parent's page dir (shared memory)
  np->pgdir = proc->pgdir;
  // This might be an issue later.
  np->sz = proc->sz;
  np->parent = proc;
  *np->tf = *proc->tf;
  
  if(argint(1, &size) < 0 || size <= 0 || argptr(0, &stack, size) < 0) {
    kfree(np->kstack);
    np->kstack = 0;
    np->state = UNUSED;
    return -1;
  }
<<<<<<< HEAD
Exemple #16
0
int
sys_alarm(void)
{
/*PID = fork();
if(PID > 0)
{
cprintf("PID: %d\n", PID);
cprintf("\nSoy el padre\n");
PID=wait();
}
else if(PID == 0)
{
cprintf("PID: %d\n", PID);
cprintf("\nSoy el hijo\n");
exit();
}*/
  int ticks;
  void (*handler)();
 /* cprintf("funciona\n");
  //cprintf("%d\n",ticksG);
  cprintf("%d\n",handler);
  cprintf("%d\n",ticks);*/
  //cprintf("%d\n",&sys_getpid);	
  if(argint(0, &ticks) < 0)
      return -1;
  if(argptr(1, (char**)&handler, 1) < 0)
      return -1;
  proc->alarmticks = ticks;
  proc->alarmhandler = handler;
  //cprintf("%d\n",proc->pid);
  //proc->ticksInicio = ticksG;
      return 0;
}
Exemple #17
0
int
sys_clone(void)
{
	char* p1;
	char* p2;
	//void(*fcn)(void*);
	char* p0;
	
    if(argptr(0, &p0, 4 < 0 || argptr(2, &p2, 4)  < 0 || argptr(1, &p1, 1) < 0)) 
		return -1;
	
	/*p1 = (void*)p1;
	p2 = (void*)p2;
	p0 = (void (*)(void *))p0;*/
	return clone((void (*)(void *))p0, (void*)p1, (void*)p2);
}
Exemple #18
0
int sys_join(void){
	void** stack;
	if(argptr(0, (void*)&stack, sizeof(void *)) < 0){
		return -1;
	}
	return join(stack);
}
Exemple #19
0
//TODO shai start
int
sys_wait2(void){
  char *wtime;
  char *rtime;
  //check and init the arguments
  int check = argptr(0, &wtime, sizeof(wtime));
  check = check + argptr(1, &rtime, sizeof(rtime));
  //execute if args are correct
  if(!check){
    return (wait2((int*)wtime, (int*)rtime));
  }
  else{
   return -1; 
  }
  
}
Exemple #20
0
int sys_restore(void)
{
	char *p = 0;
	if (argptr(0, &p, sizeof(struct checkpoint_t)) < 0)
		return -1;
	return restore((struct checkpoint_t *)p);
}
Exemple #21
0
int
sys_write(struct file *f, char *p, int n)
{
  if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0)
    return -1;
  return filewrite(f, p, n);
}
Exemple #22
0
//returns pstat with some basic information about each running process
//how many times its run, pid, and which queue its on(high or low)
int sys_getpinfo(void)
{
   struct pstat *ps;
   if(argptr(0,(void*)&ps,sizeof(struct pstat *) < 0)) return -1;
   //*ps = proc->pstat_t;
   *ps = pst;
   return 0; }
Exemple #23
0
int
sys_fstat(struct file *f, struct stat *st)
{
  if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0)
    return -1;
  return filestat(f, st);
}
Exemple #24
0
int sys_history(void) {
	int n;
	char * p;
	argptr(0, &p, 128);
	argint(1, &n);
	return history(p, n);
}
Exemple #25
0
int sys_getMsg()
{
	struct Msg* ptr;
	if (argptr(0, (void*)&ptr, sizeof(*ptr)) < 0)
		return -1;
	getMsg(proc->pid, ptr);
	return 0;
}
Exemple #26
0
int
sys_sem_broadcast(void)
{
  struct semaphore * sem;
  argptr(0, (char **) &sem, sizeof(struct semaphore*));
  sem_broadcast(sem);
  return 0;
}
int
sys_gettime(void) {
  struct rtcdate *d;
  if (argptr(0, (char **)&d, sizeof(struct rtcdate)) < 0)
      return -1;
  cmostime(d);
  return 0;
}
Exemple #28
0
int
sys_exit(void)
{
  int status;
  argptr(0, (char **) &status, 4);
  exit(status);
  return 0;  // not reached
}
Exemple #29
0
int
sys_cvwait(void)
{
  void *cond;
  void *lock;
  if(argptr(0,(char**)&cond,sizeof(cond))<0)
  {
        return -1;
  }
  if(argptr(1,(char**)&lock,sizeof(lock))<0)
  {
        return -1;
  }

  cvwait(cond,lock);
  return 0;
}
Exemple #30
-1
int
sys_wait2(void)
{
  char *rtime=0;
  char *wtime=0;
  argptr(1,&rtime,sizeof(rtime));
  argptr(0,&wtime,sizeof(wtime));
  return wait2((int*)wtime, (int*)rtime);
}