home tutorials faq contact
CS tutorials Share you information

Lab 2: Tutorial

This is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.

What is syscall.h ???

syscall.h resides in userprog directory and it contains the macros defining the code numbers of system calls and the prototypes of the system calls. The user programs which you will write for your test cases will follow the format of the system calls defined in syscall.h. The implementations of all system calls will go in the exception.cc.

Let me give you an explaination of each System call.

Create(char* name)

Create system call creates a file with the name "name" given as the parameter.

else if ((which == SyscallException) && (type == SC_Create)) 
      {
      int virtualaddress = machine->ReadRegister(4); 

      //This is the argument of the Create system call(in register r4) 
      //but this is an integer and this is the starting virtual address
      //of the name of the file to be created . so it needs to be 
      //   converted to the physical address 
      // for this you can copy and paste the Translate & ReadMem 
      // functions of machine class and make use of those functions
      // Those functions are implemented in translate.cc in machine
      //directory.
      ...........
      .........
      Now after you get translated the virtual address to the 
      physical address , you can get the name of the file
      as char* from that physical address 
	       
   ***check whether file already exists or not , If the file 
      with the same name exists then return and display error

   ***If not then call 
      fileSystem->Create(... , ...);
      add the name to the list
  NOTE: This list should be globally defined 
   }

...

//----------------------------------------------------------------------
// Create_Syscall
//	Create the file with the name in the user buffer pointed to by
//	vaddr.  The file name is at most MAXFILENAME chars long.  No
//	way to return errors, though...
//
//	"vaddr" -- The filename is stored in the string at this virtual
//	address.
//----------------------------------------------------------------------
void Create_Syscall(unsigned int vaddr) 
{
	// Kernel buffer to put the name in
    char *buf = new char[MAXFILENAME];	

    if (!buf) return;

    if ( copyinz(vaddr,MAXFILENAME,buf) == -1 ) 
	{
		synchConsole->WriteLine("System Error: Bad pointer passed to Create.\n");
		delete buf;
		return;
    }
	
	// Do some error checking before passing it to the filesystem
    if (strcmp(buf, "") == 0)
    {
		synchConsole->WriteLine("System Error: Invalid name for file.\n");
		delete buf;
		return;
    }

    fileSystem->Create(buf,0);
    delete buf;
    return;
}

This is ONLY a preview of the tutorial. If you would like to view the entire tutorial, you must purchase the tutorial.

Each tutorial comes with the following:

  • Assignment overview. Details on each topic in a general level and how they are implemented in Nachos.

  • Walk-through. A complete step-by-step guide on how to implement the code necessary to complete each assignment.

  • Frequently asked questions. Questions and answers to common problems students face while completing each assignment.

  • Helpful links. Links to academic and other websites that offer Nachos assistance and documentation.

  • Documentation. Detailed documentation listing all of the classes, structures, functions defined in Nachos.

  • Roadmap. High-level overview of the source code, focusing on the big picture rather than on the details.

  • Source code. The source code solution to each assignment.

This includes both documentation on understanding the concepts for each assignment and how to get started. Topics are accompanied with animations.

All 5 Assignments Tutorial Package

$149.99
Save 40%

Thread Synchronization Assignment Tutorial

$29.99

Multiprogramming and System Calls Assignment Tutorial

$49.99

Virtual Memory Assignment Tutorial

$49.99

Distributed Networking Assignment Tutorial

$39.99

File System Assignment Tutorial

$39.99

Nachos
Tutorials
Roadmap
Source Code

Introduction
Threads
Interrupts
Synchronization
System Calls
Exception Handling
Multiprogramming
File System
Networking

Tutorials
Lab 1 Tutorial
Lab 2 Tutorial
Lab 3 Tutorial
Lab 4 Tutorial
Lab 5 Tutorial


© 1999-2008 - All rights reserved. CS tutorials™ and the logo are registered trademarks of CS tutorials.