-
Notifications
You must be signed in to change notification settings - Fork 0
Gitwick/sap {DRAFT} #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ | |
| #define MAXPATH 128 // maximum file path name | ||
| #define NDISK 2 | ||
| #define NNETIF 2 | ||
| #define NTHREAD 128 // 2*NPROC | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,26 @@ struct trapframe { | |
|
|
||
| enum procstate { UNUSED, SLEEPING, RUNNABLE, RUNNING, ZOMBIE }; | ||
|
|
||
| struct thread | ||
| { | ||
| struct spinlock lock; | ||
|
|
||
| // t->lock must be held when using these: | ||
| int tid; | ||
| enum procstate state; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this. We need a pointer to parent proc itself. |
||
|
|
||
| // these are private to thread, lock need not be held | ||
| struct context context; | ||
| }; | ||
|
|
||
| // linked list for dynamic thread allocation | ||
| struct threadlist | ||
| { | ||
| struct thread *tcb; | ||
| struct threadlist *next; | ||
| }; | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While the fancy list is nice and gives a container like ability, but let's keep things simple for now and just use an array. |
||
|
|
||
| // Per-process state | ||
| struct proc { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove trapFrame from here. |
||
| struct spinlock lock; | ||
|
|
@@ -103,4 +123,6 @@ struct proc { | |
| struct file *ofile[NOFILE]; // Open files | ||
| struct inode *cwd; // Current directory | ||
| char name[16]; // Process name (debugging) | ||
| }; | ||
|
|
||
| struct threadlist *threads; // Data structure to handle dynamic allocation of threads | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,6 @@ | |
| // System calls for labs | ||
| #define SYS_ntas 22 | ||
| #define SYS_nfree 23 | ||
|
|
||
| // DHAGA calls | ||
| #define SYS_clone 24 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,3 +95,9 @@ sys_uptime(void) | |
| release(&tickslock); | ||
| return xticks; | ||
| } | ||
|
|
||
| uint64 | ||
| sys_clone(void) | ||
| { | ||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #include "kernel/types.h" | ||
| #include "kernel/stat.h" | ||
| #include "user/user.h" | ||
|
|
||
| void | ||
| dhagatest() | ||
| { | ||
| if(clone((void *)0,0)!=0) | ||
| { | ||
| printf("clone should return zero\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| printf("all tests passing\n"); | ||
| } | ||
|
|
||
| int | ||
| main(void) | ||
| { | ||
| dhagatest(); | ||
| exit(0); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,3 +38,4 @@ sub entry { | |
| entry("uptime"); | ||
| entry("ntas"); | ||
| entry("nfree"); | ||
| entry("clone"); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need trapframe here.