Giter VIP home page Giter VIP logo

os-assign's Introduction

OS Project

Title : Operating System Project 3 - Synchronization

Author : 201420973 SWCT KwonMinJae, 201420995 SWCT ParkSungMi

Project # : #1 The Sleeping Teaching Assistant

Description : Manage the students (threads) and helping task

Compile and Run

  1. make
  2. ./simulator

Structure

  1. student: student threads have own semaphore
  2. ta: ta thread has own semaphore

Functions

  1. stu_programming: students is waiting in random time (they are programming in this time), and notice to ta for help. if ta is helping a student already, other students are waiting chairs in hallway, but if chairs is full, students go to their programming task back
  2. ta_teaching: ta is sleeping until notice is arrived from at least one student. if any student wake the ta up, ta will help the student. if helping is finished and chairs are empty, then ta go to sleeping back
  3. rand_sleep: make sleeping time (it means programming task or helping tesk) randomly

Simple process flows

  1. make student threads and ta thread (initialize)
  2. each thread is running own thread function (student is programming, ta is sleeping)
  3. student will wake the ta up after randomly time, then ta will help the arrived student (change student's semaphore to 1 and wait ta's semaphore). but if chairs are full, students go to their programming back and return again after randomly time
  4. if ta's help is finished, ta check the remaining students. if there is(are) student(s) ta is keeping the current state (help continuously) and if not, ta go to sleeping back (change ta's semaphore to 1 and wait student's semaphore)
  5. repeat 3-4 steps

os-assign's People

Contributors

mingrammer avatar parksungmi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

os-assign's Issues

error!!

hey,
I m getting few error in line 44 and few lines
error: invalid conversion from ‘void* ()()’ to ‘void ()(void)’ [-fpermissive]
44 | pthread_create(&ta,NULL,ta_teaching,NULL);
| ^~~~~~~~~~~
| |
| void* ()()
In file included from main.cpp:12:
/usr/include/pthread.h:200:15: note: initializing argument 3 of ‘int pthread_create(pthread_t
, const pthread_attr_t*, void* ()(void), void*)’
200 | void (__start_routine) (void ),
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘void
stu_programming(void*)’:
main.cpp:60:15: error: cast from ‘void*’ to ‘int’ loses precision [-fpermissive]
60 | int id = (int)stu_id;
| ^~~~~~
main.cpp: In function ‘void rand_sleep()’:
main.cpp:103:1: error: ‘sleep’ was not declared in this scope
103 | sleep(time);
| ^~~~~
can u tell if anything's missing !!

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.