diff options
| -rw-r--r-- | asm/int_clock_handler.asm | 2 | ||||
| -rw-r--r-- | fs/file.c | 2 | ||||
| -rw-r--r-- | fs/file.h | 6 | ||||
| -rw-r--r-- | fs/foolfs.h | 0 | ||||
| -rw-r--r-- | fs/mount.c | 12 | ||||
| -rw-r--r-- | fs/mount.h | 14 | ||||
| -rw-r--r-- | kernel/syscalls.c | 1 | ||||
| -rw-r--r-- | userspace/foolshell.c | 2 | ||||
| -rw-r--r-- | userspace/sys/syscalls.c | 9 | ||||
| -rw-r--r-- | userspace/task1.c | 43 |
10 files changed, 74 insertions, 17 deletions
diff --git a/asm/int_clock_handler.asm b/asm/int_clock_handler.asm index 5e48658..7b0afaf 100644 --- a/asm/int_clock_handler.asm +++ b/asm/int_clock_handler.asm @@ -5,7 +5,7 @@ global int_clock_handler int_clock_handler: -cli +cli pusha ;Push all standard registers mov eax, esp ;save current stack pointer in esp @@ -1,2 +1,4 @@ #include "file.h" + + @@ -3,6 +3,8 @@ #include <stdint.h> +#define FILE_MAX_FILES 100; + typedef struct { int(* seek)(int offset, int whence); @@ -17,4 +19,8 @@ typedef struct }file; + + + + #endif diff --git a/fs/foolfs.h b/fs/foolfs.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/fs/foolfs.h diff --git a/fs/mount.c b/fs/mount.c new file mode 100644 index 0000000..616262d --- /dev/null +++ b/fs/mount.c @@ -0,0 +1,12 @@ +#include "mount.h" + +void mount_add(char *path, void *data, + file (*open)(struct mount_struct*,char *path), + int (*getdents)(struct mount_struct*, uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count)) +{ +} + +mount *mounts_get() +{ + return 0; +} @@ -3,15 +3,23 @@ #define MOUNT_MAX_MOUNTS 10 -typedef struct mount_strutc +#include <stdint.h> +#include "file.h" +#include "fs.h" + +typedef struct mount_struct { char path[256]; // where are we mounted - int (*getdents)(mount_struct*, uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count); - file (*open)ByName(mount_struct*,char *path); + int (*getdents)(struct mount_struct*, uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count); + file (*open)(struct mount_struct*,char *path); void *data //opaque }mount; mount *mounts_get(); +void mount_add(char *path, void *data,file (*open)(struct mount_struct*,char *path),int (*getdents)(struct mount_struct*, uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count)); + + + // #endif diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 67a8aa6..642f04a 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -44,6 +44,7 @@ int syscall_write(int file, char *buf, int len) { fifo_put(&get_fool()->std_out,buf[i]); } + lock_release(2); //x86_int_enable(); return len; diff --git a/userspace/foolshell.c b/userspace/foolshell.c index bf0501f..2abb549 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -227,7 +227,7 @@ int process(char *buf) int pid=fork(); if(pid!=0) { -// printf("new task pid: %i \n",pid); + printf("new task pid: %i \n",pid); } if(pid==0) { diff --git a/userspace/sys/syscalls.c b/userspace/sys/syscalls.c index e6a6a4d..9dfd313 100644 --- a/userspace/sys/syscalls.c +++ b/userspace/sys/syscalls.c @@ -92,8 +92,6 @@ int gettimeofday(struct timeval *tv, void *tz) return syscall(SYSCALL_GETTIMEOFDAY,tv,tz,0); } - - int fork(void) { return syscall(SYSCALL_FORK,0,0,0); @@ -109,9 +107,6 @@ int kill(int pid, int sig) return syscall(SYSCALL_KILL,pid,sig,0); } - - - int link(char *old, char *ne) { return syscall(SYSCALL_LINK,old,ne,0); @@ -122,20 +117,16 @@ int unlink(char *name) return syscall(SYSCALL_UNLINK,name,0,0); } - - int times(struct tms *buf) { return syscall(SYSCALL_TIMES,buf,0,0); } - int wait(int *status) { return syscall(SYSCALL_WAIT,status,0,0); } - int stat(const char *file, struct stat *st) { return syscall(SYSCALL_STAT,file,st,0); diff --git a/userspace/task1.c b/userspace/task1.c index d3706ee..d9875f4 100644 --- a/userspace/task1.c +++ b/userspace/task1.c @@ -1,11 +1,48 @@ -int main(int argc, char **argv) +typedef unsigned long long ULL; + +// a simple cache to speedup successive requests! +static ULL fib1_cached_index=0; +static ULL fib1_cached_value=0; + +static ULL fib2_cached_index=1; +static ULL fib2_cached_value=1; + + +ULL fib(ULL i) { - signed int i=0; + if(i==0)return 0; + if(i==1)return 1; + if(i==fib1_cached_index)return fib1_cached_value; + if(i==fib2_cached_index)return fib2_cached_value; + + ULL value=fib(i-1)+fib(i-2); + + fib1_cached_index=fib2_cached_index; + fib1_cached_value=fib2_cached_value; + + fib2_cached_index=i; + fib2_cached_value=value; + + return value; +} + + + +int main(unsigned int argc, char **argv) +{ + ULL i=0; while(1) { i++; - printf("task 1 : %i \n",i); + + fib(i); //precalc + + // this will exhaust the stack so we call fib every time above + #ifdef __linux__ + if((i%100000000)==1)printf("gcc-fibonacci(%llu) = %llu \n",i,fib(i)); + #endif + if((i%100000000)==1)printf("fibonacci(%u...) = %u... \n",(unsigned)i,(unsigned)fib(i)); } return 0; |
