C++ & Systems Projects

Introduction

During my spring quarter of Freshman year, I had the opportunity to take cs110 with Prof. Gregg. I really enjoyed both the students, TAs and professors of this course and I also really enjoyed the content I learned from the course. The topics--like file systems, networking or multi threaded or processed code--were the topics that when I first began CS I dreamed of learning (okay--maybe I didn't dream about file systems in the beginning, but I was really excited to learn them in cs110 which is why I gave them the courtesy of inclusion).

90% of the code in the class was written in C++ and the other 10% in C. I credit this class along with cs107e for my comfort with and admiration for C/C++.

Some of the assignments that I really enjoyed doing in this class included making a proxy server, implementing a shell, implementing ThreadPool, and implementing MapReduce. I'd like to give two big disclaimers here: (1) I cannot share any code associated with these assignments as they were done for courses and (2) I did not write all of the code for these assignments because each included starter code, some of which was quite significant. But feel free to ask me questions about and of the projects if you'd like to know more about what I did!

Proxy Server

One of the most applicable projects of the class, Proxy Server was pretty much exactly what it sounds like. More specifically, it is an HTTP only proxy server that supports proxy chaining and is limited to GET, POST and HEAD requests (which make up the vast majority of HTTP requests and provides sufficient functionality to browse most HTTP sites).

For this assignment, I utilized concepts like HTTP requests (going into the fine details like how each line must be ended in a carriage return and a new line and other structural details of headers and bodies), sockets, Linux system calls for networking, ThreadPools.

STSH (Shell)

This assignment was to implement our own working and fully functional shell (practically everything you can do with Terminal or Git Bash you can do with this shell). For example, you can run programs in the foreground and background. You can run multiple programs at the same time and pipe them, or have them write or read from files or STDIN/STDOUT. You can use emacs to open a file. The shell also has a few standard builtin commands like Halt, Slay, Fg, and Bg. You can even run the shell executable within the shell. You can run the shell, ssh into your own computer, then run the shell again. Shell-ception!

I utilized multiprocessing, file descriptors, PIDs, signals, signal blocking and signal handlers and Linux system calls like fork, dup, waitpid, execvp, or sigprocmask.

ThreadPool

This assignment implemented a ThreadPool class that accepts thunks in a queue and spawns off a set number of workers to process these thunks. Given a threadpool of size n, there would be n+1 threads in my implementation of ThreadPool--n for each worker and 1 for the enqueueing of work.

ThreadPool utilizes object oriented programming, multithreading, semaphores, condition variable anys, mutexes (mutices--like vertices?). ThreadPool doesn't deal directly with pthreads, but instead uses a provided thread wrapper that is implemented (not by me) with pthreads.

MapReduce

MapReduce was the final project in cs110 and the culmination of our work in multithreading. We implement the MapReduce algorithm which is able to take a large problem, distribute and perform simultaneous piecewise work in a mapping stage and then culminate processed chunks of work into a final solution in a reducing stage.

MapReduce uses my implementation of ThreadPool, a variety of system calls for file writing and reading, and actually uses system (instead of execvp) to ssh into other machines to distribute work through more computational power. MapReduce leverages objected oriented programming and inheritance for organization.