Permalink
Browse files

fork new addrsspace

  • Loading branch information...
1 parent c055f87 commit 476a1cac5bef360de1ebebb091f58fd710bdedd6 Vivek Anand T Kallampally committed Mar 29, 2012
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
BIN test/fork
Binary file not shown.
View
@@ -1,24 +1,24 @@
#include "syscall.h"
+int i;
void p()
{
- int i=0;
while(i++ < 10)
Print("Hi");
Exit(0);
}
void func()
{
-Print("****hi****\n");
- Fork(p);
+ Print("****hi****\n");
+ // Fork(p);
+ i=Exec("./test/open");
Print("###############Hey###############\n");
Exit(0);
}
void main()
{
- int i=0;
- Print("Hello\n");
+ Print("Hello\n");
Fork(func);
-// Fork(p);
+
// Fork(func);
// Join(i);
Print("hello after fork\n");
View
Binary file not shown.
View
Binary file not shown.
View
BIN test/open
Binary file not shown.
View
@@ -10,5 +10,5 @@ void main()
Read(buf,20,fd);
Print(buf);
Close(fd);
- Halt(); // Optional. Just print stats
+ //Halt(); // Optional. Just print stats
}
View
Binary file not shown.
View
Binary file not shown.
View
@@ -142,6 +142,47 @@ void AddrSpace::AllocateAddrSpace(OpenFile *executable)
}
}
+AddrSpace::AddrSpace()
+{
+}
+AddrSpace::AddrSpace(const AddrSpace &src)
+{
+ int i;
+ numPages = src.numPages;
+ ASSERT(numPages <= NumPhysPages); // check we're not trying
+ // to run anything too big --
+ // at least until we have
+ // virtual memory
+
+ DEBUG('t', "Initializing address space, num pages %d\n",
+ numPages);
+// first, set up the translation
+ pageTable = new TranslationEntry[numPages];
+ for (i = 0; i < numPages; i++) {
+ pageTable[i].virtualPage = i; // for now, virtual page # = phys page #
+ pageTable[i].physicalPage = allocate();
+ pageTable[i].valid = TRUE;
+ pageTable[i].use = FALSE;
+ pageTable[i].dirty = FALSE;
+ pageTable[i].readOnly = FALSE; // if the code segment was entirely on
+ // a separate page, we could set its
+ // pages to be read-only
+ }
+
+// zero out the entire address space, to zero the unitialized data segment
+// and the stack segment
+ //bzero(machine->mainMemory, size);
+ for(i=0; i<numPages; i++)
+ {
+ bzero( &(machine->mainMemory[pageTable[i].physicalPage * PageSize]), PageSize );
+ }
+
+// then, copy in the code and data segments into memory
+ for(i=0; i<numPages; i++)
+ {
+ memcpy(&(machine->mainMemory[pageTable[i].physicalPage * PageSize]),&(machine->mainMemory[src.pageTable[i].physicalPage * PageSize]),PageSize);
+ }
+}
//----------------------------------------------------------------------
// AddrSpace::~AddrSpace
View
@@ -20,6 +20,8 @@
class AddrSpace {
public:
+ AddrSpace();
+ AddrSpace(const AddrSpace &);
void AllocateAddrSpace(OpenFile *executable); // Create an address space,
// initializing it with the program
// stored in the file "executable"
View
Binary file not shown.
View
@@ -323,6 +323,7 @@ ExceptionHandler(ExceptionType which)
thread->ChangeUserReg(4,0);
thread->ChangeUserReg(PCReg, arg1);
thread->ChangeUserReg(NextPCReg, arg1 + 4);
+ //currentThread=thread;
thread->Fork((VoidFunctionPtr)StartUserThread, arg1);
currentThread->Yield();
machine->WriteRegister(2,pid-1);
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
BIN vm/main.o
Binary file not shown.
View
Binary file not shown.
View
BIN vm/nachos
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit 476a1ca

Please sign in to comment.