Giter VIP home page Giter VIP logo

sprint-challenge--processes-and-scheduling's Introduction

Sprint Challenge: Processes and Scheduling

Multiple Choice and Short Answer Questions

Add your answers to the Answers.md doc.

  1. Assume we have two processes, P1 and P2, that have both been initialized, and let's assume that each process on this machine is initially allocated 32 KB of memory as its address space. What are the possible address space ranges each process could have? Write a short paragraph explaining your answer.

    a. P1: 0 - 32,000; P2: 32,001 - 64,000

    b. P1: 0 - 64,000; P2: 0 - 64,000

    c. P1: 32,001 - 64,000; P2: 0 - 32,000

  2. List all of the possible states a process may be in at any point in time. Briefly explain what each of these states mean.

  3. On your machine, how much faster does a printf call take compared to how long a write system call takes?

  4. printf is a C library function that calls the write system call under the hood. What are some possible reasons as to why printf runs faster than write?

Programming Exercise 1

Add your code in the ex1/ex1.c file.

Write a function that allocates an array of ints of a specified size. (The cols parameter holds the size.)

int *alloc_1d(int cols)
{
	// !!! IMPLEMENT ME
	// (solution is about 2 lines of code)
}

void alloc_1d_example(void)
{
	int *my_array = alloc_1d(12);

	my_array[8] = 3490;

	// The same array access could be made with pointer arithmetic:
	*(my_array+8) = 3490;

	// By the C spec, the array notation and pointer arithmetic notation
	// are 100% equivalent.

	printf("my_array[8] = %d\n", my_array[8]);
}

Programming Exercise 2

Add your code in the ex2/ex2.c file.

Write a function that allocates a two-dimensional array of ints of a specified size. (The rows parameter is how many rows in the array, and cols is how many columns per row.)

int **alloc_2d(int rows, int cols)
{
	// !!! IMPLEMENT ME
	// (solution is about 5 lines of code)
}

void alloc_2d_example(void)
{
	int **my_array = alloc_2d(5, 10);

	// First array index is row, second is column:
	my_array[2][3] = 3490;

	// The same array access could be made with pointer arithmetic:
	*(*(my_array+2)+3) = 3490;

	// By the C spec, the array notation and pointer arithmetic notation
	// are 100% equivalent.
	
	printf("my_array[2][3] = %d\n", my_array[2][3]);
}

sprint-challenge--processes-and-scheduling's People

Contributors

seanchen1991 avatar cosmonautjones avatar

Watchers

James Cloos 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.