Code Monkey home page Code Monkey logo

designdoc2's Introduction

Data Structures and Functions

Add a function that will parse the arguments and put it in an array to process.c.

void parse_arguments(char *input) 
{
  char args [1024];
  char *tokens = strtok_r(input, " ");
  while(tokens != null){
  	args[i] = tokens;
	}
    }
 

process_execute() will create a user program with "filename" as the arguments. We will call the function we created parse_arguments(filename) to parse the user input and pushed them to the stack. We will also perform a check to see if the arguments are valid.

Algorithms

In setup_stack() we call parse_arguments(char *input) where we will call strtok_r() with a space as the delimiter. We store each of these tokens in an array and increase our argc at the same time. When we push these tokens onto the stack we start with the last one to the first one, pushing each pointer onto the stack. This way, we will get each element of argv[] to be in the right order. To avoid overflowing the stack page we limited the size of the total arguments to be less than one page size (4 KB).

Synchronization

When a user program is started, we create a thread to handle the each user program started therefore, we will also modify process_wait() such that when a child process is created, the parent process will wait for this process to finish loading properly, then proceed to continue with its execution.

Rationale

  • We chose to use strtok_r instead of strtok because its thread safe i.e it is reentrant.
  • we will be pushing the parsed user arguments into the stack to esp. Pushing the user arguments to esp will ensure that the arguments are ran.

designdoc2's People

Contributors

pkoech avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.