assignments

Both homeworks and projects are detailed below.

Assignments are to be completed individually, as specified in the assignment description. Projects are to be completed either individually or in teams of up to three students. Teamwork is not required for any assignments.

Unless otherwise noted, assignments are due by midnight on the specified due date and are to be submitted via this link. Log in using either your RCS ID and password or your CS ID and password.

Unix environments

With multiple versions of Unix available, please be sure to use BSD Unix for homeworks and projects detailed below. CS Department machines include ashley.cs.rpi.edu, mary-kate.cs.rpi.edu, and monica.cs.rpi.edu.

Compilation

Use gcc to compile your code (and specify -Wall to ensure all compiler warnings are addressed before submitting your assignment).

Instructor: David Goldschmidt, Ph.D.
Office Hours: after class
Email: click here to email me
Jing Fu
TA: Jing Fu
Office Hours: Wed 8:30-10:30am & Thurs 10:00am-12:00pm (in AE 217)
Email: fuj@cs.rpi.edu
Emma Zhang
TA: Li Zhang (Emma)
Office Hours: Mon & Thurs 11:30am-1:30pm
(in AE 217)
Email: emma.lzhang@gmail.com

Homework #1 - System Calls in C

Due Friday 1/23 (grade report)

Homework #2 - Process Creation in C

Due Tuesday 2/10

Homework #3 - Threads in C

Due Friday 2/20

Project #1 - Process Management Simulation System

Due Wednesday 3/4

Homework #4 - Client-Server Programming using Sockets

Due Tuesday 4/14

Project #2 - Memory Management Simulation System

Due Tuesday 4/28

« hide details

This project is to be completed individually or in teams of up to three students. Beyond your team, do not share code or review anyone else's code.

Submit your project via this link as a single compressed and zipped file (using tar and gzip); include only source code and documentation files. Log into the submission site using either your RCS ID and password or your CS ID and password.

Be sure to comment your code and include your name(s) at the top of each file submitted.

Initialialization:
On campus BSD Unix systems, using C, C++, Java, or Python (contact the instructor if you'd like to use another language), design and implement a simulation program for memory management in an operating system.

Use a 1-dimensional character array of size 2400 to represent main memory. Each cell of the array represents an equally sized chunk of memory. The resident operating system processes are fixed in size and loaded into memory at array locations 0-79.

Using continguous memory allocation, assign 20 user processes to memory, each process requiring a random amount (in the range 10-100) of memory cells. Use the following character mappings:

  • A '.' character represents a free memory cell.
  • A '#' character represents an operating system process memory cell.
  • An ASCII character in the range 'A'-'Z' and 'a'-'z' (i.e. uppercase and lowercase letters) represents a user process memory cell. Feel free to use the character sequence A-Z[\]^_`a-z if it makes implementation easier.

Cycle through the character set to uniquely identify each process, looping back to 'A' after process 'z' has been allocated. Be sure no duplicates are used (i.e. to reuse 'A', first be sure memory is not still allocated to 'A').

In general, as your simulation attempts to place processes in memory, it's possible you will not be able to allocate a contiguous block of memory. If this occurs, display an error message (e.g. OUT-OF-MEMORY) and exit the simulation.

Once your simulation has been set up, show the memory allocation by displaying your array 80 characters to a line, as in:

################################################################################
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEFFFFFFFFF
FFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
JJJJJJJJJJJJJJJJJJJJJJJJJJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKLLLLLLLLLLLLLLLLLLL
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMM
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPQQQQQQQQQQQQQQQQQQQ
QQQQQQQQRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTT
TTTT............................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................

Simulation:
Use a command-line argument to specify the type of memory allocation algorithm to use. Your program must be called memsim and follow these usage specifications:

bash-3.2$ memsim
USAGE: memsim  { first | best | next | worst }  <new-proc-prob>
bash-3.2$ memsim first 40
...
bash-3.2$ memsim best 30
...
bash-3.2$ memsim next 40
...
bash-3.2$ memsim worst 60
...

Create a loop controlled by the user (see below); at each iteration, two types of events occur in the given order:

  1. Processes exit the system: each process has a 20% probability of terminating, in which case its memory is marked as free;
  2. A new process enters the system: a new process enters the system with probability <new-proc-prob> (as specified on the command-line), requiring a random amount (10-100) of memory cells.

At each iteration of the loop, display your memory, then prompt the user to press ENTER to continue.

Use the memory allocation algorithm specified on the command-line (i.e. first-fit, best-fit, next-fit, and worst-fit).

EXTRA CREDIT: if your program reaches an OUT-OF-MEMORY condition, perform defragmentation or compaction and continue running. Display the memory once defragmentation has completed.

Compiler:
Use gcc/g++to compile your C/C++ code (and specify -Wall to ensure all compiler warnings are addressed before submitting your assignment). For Java programs, use javac to compile your code and java to execute it. For Python programs, use python (version 2.5.2) to execute your code. With multiple versions of Unix available, please be sure to use BSD Unix.