Exemple #1
0
int main() {
    MemDB_Initialize();

    CREATE_NEW_MESSAGE_PTR(msg);
    msg->MsgType = CardinalMsgType_Notification;
    msg->MsgID = 0;
    PostIPCMessages(2 /*userboot PID*/, &msg, 1);

    while(1) {
        CREATE_NEW_MESSAGE_PTR(msg);
        POLL_MESSAGE(msg);

        if(msg->MsgType == CardinalMsgType_Request) {

            MsgHeader *msg_h = (MsgHeader*)msg;

            switch(msg_h->MsgType) {
            case MemoryServerMessageType_MMapRequest: {
                mmap_handler(msg);
            }
            break;
            }


        } else
            HandleSystemMessages(msg);
    }
}
Exemple #2
0
static void syscall_handler(struct intr_frame *f) {
	void *esp = f->esp;
	thread_current()->saved_esp = f->esp;

//	printf("$esp = %p\n",esp);

	byte_access_ok(esp,false);
//    hex_dump(esp, esp,16,true);
//    printf("\n");

	int sys_call_num = *(int*) esp;
    esp += sizeof(int *);
    byte_access_ok(esp,false);

//    printf("$sys_call_num = %p\n",sys_call_num);

	char* argv[5];

	switch (sys_call_num) {
	/* Projects 2 and later. */
	//TODO: please retrieve parameters from the stack
	//      and pass them to the handlers.
	case SYS_HALT: /* Halt the operating system. */
		halt_handler();
		break;
	case SYS_EXIT: /* Terminate this process. */
		parse_arg(esp, 1, argv);
		exit_handler((int) argv[0]);
		break;
	case SYS_EXEC: /* Start another process. */
		parse_arg(esp, 1, argv);
		f->eax=exec_handler((void*)argv[0]);
		break;
	case SYS_WAIT: /* Wait for a child process to die. */
		parse_arg(esp, 1, argv);
		f->eax=wait_handler((int) argv[0]);
		break;
	case SYS_CREATE: /* Create a file. */
		parse_arg(esp, 2, argv);
		f->eax=create_handler((void*)argv[0], (unsigned) argv[1]);
		break;
	case SYS_REMOVE: /* Delete a file. */
		parse_arg(esp, 1, argv);
		f->eax=remove_handler((void*)argv[0]);
		break;
	case SYS_OPEN: /* Open a file. */
		parse_arg(esp, 1, argv);
		f->eax=open_handler((void*)argv[0]);
		break;
	case SYS_FILESIZE: /* Obtain a file's size. */
		parse_arg(esp, 1, argv);
		f->eax=filesize_handler((int) argv[0]);
		break;
	case SYS_READ: /* Read from a file. */
		parse_arg(esp, 3, argv);
		f->eax=read_handler((int) argv[0], (void*) argv[1], (unsigned) argv[2]);
		break;
	case SYS_WRITE: /* Write to a file. */
		parse_arg(esp, 3, argv);
		f->eax=write_handler((int) argv[0], (void*) argv[1], (unsigned) argv[2]);
		break;
	case SYS_SEEK: /* Change position in a file. */
		parse_arg(esp, 2, argv);
		seek_handler((int) argv[0], (unsigned) argv[1]);
		break;
	case SYS_TELL: /* Report current position in a file. */
		parse_arg(esp, 1, argv);
		f->eax=tell_handler((int) argv[0]);
		break;
	case SYS_CLOSE: /* Close a file. */
		parse_arg(esp, 1, argv);
		close_handler((int) argv[0]);
		break;
	case SYS_MMAP:
		parse_arg(esp, 2, argv);
		f->eax=mmap_handler ((int) argv[0], (void*)argv[1]);
		break;
	case SYS_MUNMAP:
		parse_arg(esp, 1, argv);
		munmap_handler ((mapid_t) argv[0]);
		break;
	default:
		printf("system call %d not implemented!\n", sys_call_num);
	}

	//thread_exit();
}
Exemple #3
0
static int file_cache_handler(request_rec *r)
{
    a_file *match;
    int errstatus;
    int rc = OK;

    /* Bail out if r->handler isn't the default value, and doesn't look like a Content-Type
     * XXX: Even though we made the user explicitly list each path to cache?
     */
    if (ap_strcmp_match(r->handler, "*/*") && !AP_IS_DEFAULT_HANDLER_NAME(r->handler)) {
        return DECLINED;
    }

    /* we don't handle anything but GET */
    if (r->method_number != M_GET) return DECLINED;

    /* did xlat phase find the file? */
    match = ap_get_module_config(r->request_config, &file_cache_module);

    if (match == NULL) {
        return DECLINED;
    }

    /* note that we would handle GET on this resource */
    r->allowed |= (AP_METHOD_BIT << M_GET);

    /* This handler has no use for a request body (yet), but we still
     * need to read and discard it if the client sent one.
     */
    if ((errstatus = ap_discard_request_body(r)) != OK)
        return errstatus;

    ap_update_mtime(r, match->finfo.mtime);

    /* ap_set_last_modified() always converts the file mtime to a string
     * which is slow.  Accelerate the common case.
     * ap_set_last_modified(r);
     */
    {
        apr_time_t mod_time;
        char *datestr;

        mod_time = ap_rationalize_mtime(r, r->mtime);
        if (mod_time == match->finfo.mtime)
            datestr = match->mtimestr;
        else {
            datestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
            apr_rfc822_date(datestr, mod_time);
        }
        apr_table_setn(r->headers_out, "Last-Modified", datestr);
    }

    /* ap_set_content_length() always converts the same number and never
     * returns an error.  Accelerate it.
     */
    r->clength = match->finfo.size;
    apr_table_setn(r->headers_out, "Content-Length", match->sizestr);

    ap_set_etag(r);
    if ((errstatus = ap_meets_conditions(r)) != OK) {
       return errstatus;
    }

    /* Call appropriate handler */
    if (!r->header_only) {
        if (match->is_mmapped == TRUE)
            rc = mmap_handler(r, match);
        else
            rc = sendfile_handler(r, match);
    }

    return rc;
}