GithubHelp home page GithubHelp logo

assignment_4_cmput_379's Introduction

Project Report

Name: Matthew Braun ID: 1497171

Objectives

The objectives of this assignment were to gain experience with multithreading, process synchronization, and preventing deadlocks when using shared variables and pthreads.

Design Overview

This project was designed in a single using C++ Important features of this project:

  1. Task class: Each task is stored in this class to keep track of busy time, wait time, running time, etc. It contains a function to check if all the resources the task needs are available before occupying them.
  2. task_thread function: This is a thread function for each task specified in the input file
  3. monitor_thread function: This is another thread function that prints info about the task states every monitor_time seconds.

Project Status

The project is currently in the following state:

  • Status: The program seems to be working as expected for the most part.
  • Known issues: When a task finishes its iteration, each task is not completing iterations in fixed increments of time like it shows in the assignment descriptions (600 msec, 620 msec, 660 msec). I'm not sure if this is an issue or not.
  • Difficulties: I had some difficulties with knowing when to lock shared resources using mutexes for the dining philospher's problem. I also had issues parsing the input file using C so I used C++ stringstreams instead.

Testing and Results

The following commands were executed:

  1. ./a4w23 input_file1.txt 100 3 All tasks idle. No resources held. Running time= 591 msec
  2. ./a4w23 input_file1.txt 1000 30 All tasks idle. No resources held. Running time= 4935 msec
  3. ./a4w23 input_file2.txt 1000 5 All tasks idle. No resources held. Running time= 7952 msec

Acknowledgments

I used a few code snippets from stack overflow as well as some other sites. Source links are provided near relevant code. I also received some help during office hours. I also watched this video on the Dining Philosopher's Problem: https://www.youtube.com/watch?v=NbwbQQB7xNQ

assignment_4_cmput_379's People

Contributors

mjbraun95 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.