Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "userprog/syscall.h"
- #include <stdio.h>
- #include <syscall-nr.h>
- #include "threads/interrupt.h"
- #include "threads/thread.h"
- static void syscall_handler (struct intr_frame *);
- void
- exit_code_init(void)
- {
- struct exit_code *tmp=(struct exit_code*)malloc(sizeof(struct exit_code));
- tmp->exitCode=0;
- strlcpy (tmp->name, "NULL", sizeof tmp->name);
- root_ex=tmp;
- tmp->next=NULL;
- printf("Struct exit_code was init\n");
- }
- void
- exit_code_add(struct exit_code *t, int exCode, const char *name_ex)
- {
- struct exit_code *tmp=malloc(sizeof(struct exit_code));
- tmp=t->next;
- if (tmp==NULL)
- {
- tmp->exitCode=exCode;
- strlcpy (tmp->name, name_ex, sizeof tmp->name);
- tmp->next=NULL;
- printf("Was Add %s with %d exit code\n", tmp->name, tmp->exitCode);
- }
- else
- {
- exit_code_add(tmp, exCode, name_ex);
- }
- }
- int
- exit_code_search_target_proc(struct thread *t, struct exit_code *temp) //
- {
- struct exit_code *tmp=malloc(sizeof(struct exit_code));
- }
- void
- syscall_init (void)
- {
- intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall");
- }
- static void
- syscall_handler (struct intr_frame *f)
- {
- if ( *(int*) f->esp == SYS_WRITE) // системный вызов write
- {
- putbuf( ((const char**) f->esp)[2], ((size_t*) f->esp)[3]);
- return;
- }
- if (*(int*) f->esp == SYS_EXIT)
- {
- int exit_status = ((size_t*) f->esp)[1];
- struct thread *cur=thread_current();
- exit_code_add(root_ex, exit_status, cur->name);
- thread_exit();// вызов exit() должен завершать программу
- }
- printf ("system call!\n");
- thread_exit ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement