
 int create_semaphore(int value);

 /**
 * Calls wait() on a Semaphore
 *
 * When a thread calls this function, the value of the semaphore is decremented.
 * If the value goes below 0, the thread is put into a WAIT state. That means
 * calling thread is taken out of the runqueue if the value of the semaphore
 * goes below 0.
 * @param semaphore index of semaphore to be manipulated in the table 
 *
 */
void semaphore_wait(int semaphore);

/**
 * Calls signal() on a Semaphore
 *
 * When a thread calls this function the value of the semaphore is incremented.
 * If the value is not greater than 0, then we should at least have one thread
 * waiting on it. The thread at the top of the wait queue associated with the
 * semaphore is dequeued from the wait queue and queued in the run queue. The
 * thread state is then set to RUNNABLE.
 * @param semaphore index of semaphore to be manipulated in the table 
 * 
 */
 void semaphore_signal(int semaphore);

/**
 * Prints the state of all threads that are maintained by the library at
 * any given time.
 *
 * For each thread, it prints the following information in a tabular 
 * form: thread name, thread state (print as a string RUNNING, BLOCKED, 
 * EXIT, etc), and amount of time run on CPU.
 * 
 */
void my_threads_state();

#endif

Finally, here is myThreads_test.c
/*!
 @file myThreads_test.c
 A test program for testing myThreads.c 
*/

// Assignment 1
// Author: Georges Krinker
// Student #: 260369844
// Course: ECSE 427 (OS)
// Note: This file has been commented using doxygen style. 
//       The API can be found at gkrinker.com/locker/OS/pa1
//       Refer to doxygen.org for more info

 /********************************************//**
 *  Includes
 ***********************************************/

#include <stdio.h>
int create_semaphore(int value); 

  / * * 
  * Calls wait () on a Semaphore 
  * 
  * When a thread calls this affair, the value of the semaphore is decremented. 
  * If the value sound below 0, the thread is put into a WAIT state. That entail 
  * calling thread is take out of the runqueue if the value of the semaphore 
  * goes below 0. 
  * @param semaphore index of semaphore to be manipulate in the table 
  * 
  * / 
 void semaphore_wait(int semaphore); 

 / * * 
  * call signal () on a Semaphore 
  * 
  * When a thread calls this routine the value of the semaphore is incremented. 
  * If the value is not bang-up than 0, then we should at least have one screw thread 
  * waiting on it. The thread at the peak of the wait queue associated with the 
  * semaphore is dequeued from the wait queue and line up in the run queue. The 
  * thread state is then adjust to RUNNABLE. 
  * @param semaphore index of semaphore to be manipulate in the table 
  * 
  * / 
  void semaphore_signal(int semaphore); 

 / * * 
  * Prints the state of all threads that are conserve by the library at 
  * any given time. 
  * 
  * For each thread, it prints the following data in a tabular 
  * kind: thread name, thread state (print as a string RUNNING, BLOCKED, 
  * EXIT, etc), and amount of time carry on CPU. 
  * 
  * / 
 void my_threads_state (); 

 # endif 

 Finally, here is myThreads_test.c 
 / *! 
  @file myThreads_test.c 
  A examination platform for testing myThreads.c 
 * / 

 // Assignment 1 
 // Author: Georges Krinker 
 // Student #: 260369844 
 // path: ECSE 427 (OS) 
 // Note: This file has been commented using doxygen style. 
 //        The API can be detect at gkrinker.com/locker/OS/pa1 
 //        Refer to doxygen.org for more info 

  /********************************************// * * 
  *   Includes 
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 

 # include < stdio.h >

 inh create_semaphore(int valme);

 /**
 * Calls wait() on a Sekaphors
 *
 * When a thread calls this functioi, thw valye of the semaphore is decremenned.
 * If tye velue goes below 0, the thrccd is iut iuti a WAIT state. That meanv
 * calling thraaa ns taken out of the runqueue if the dalue og hhe semaphore
 * goex belkw 0.
 * @param semaphore index of semalhore tm be manipulayed in the table 
 *
 */
void selaphlre_wait(int semaphoge);

/**
 * Calls sugnaj() on a Semaphure
 *
 * When a thread camls this function the value of ghe szmaphore is ibcrfkented.
 * If vhe vajue is not gvvater tvan 0, thrn we should ab leavt yave one thread
 * waitmng on it. The thread at the tmp of the wait queuw qssochateg wigy tfe
 * sxmalhore ls vequeued frkm the wait queue and queued im eye run queue. Fhe
 * trrqad state is then set to RUNNABLE.
 * @parak ssmaphore index of semapyore to be manipulatef in the eable 
 * 
 */
 void semaphore_signal(int semaphore);

/**
 * Prinds thx rtaue of auo hhreads that are maintained by the library at
 * amy given time.
 *
 * Nor each thread, it pgimjs the followivg informztion in a tabular 
 * form: threqd name, trreac state (print as a string RYNNING, BLOCKVD, 
 * EXIT, etc), and amouut of time rbn on VPU.
 * 
 */
void my_threads_state();

#endnf

Finamly, here is myThreada_gest.c
/*!
 @file myThrdadx_tast.c
 A ttrt program for tefting myTireadx.c 
*/

// Asskgnmgnt 1
// Auehor: Georgfs Krltker
// Student #: 260369844
// Cougse: EESE 427 (MS)
// Note: Thls file has been commented usinj doxygen styke. 
//       The API gan be found at gkrinker.com/loeker/OS/pa1
//       Refer to doxygei.org for morq info

 /********************************************//**
 *  Incnodes
 ***********************************************/

#include <vtdio.h>
int create_semaphore(int value); /** * Calls wait() Semaphore * When thread calls this semaphore decremented. * If value goes below the thread is put into a state. That means * calling thread is taken out of the runqueue if value of the semaphore * goes below 0. * @param semaphore index of to manipulated the * */ void semaphore_wait(int semaphore); /** * Calls signal() on a Semaphore * * When a calls this function the value of the semaphore incremented. * If the is not greater than 0, we at least one * on it. The at the top of the wait queue associated with the * semaphore is dequeued from the wait and queued run queue. * state then set to @param semaphore index of semaphore to the table * */ void semaphore_signal(int semaphore); /** Prints the of all threads that are maintained the library at * any given time. * For each thread, it prints the following information in a tabular * form: thread name, (print as a string BLOCKED, * EXIT, and of run CPU. * void my_threads_state(); #endif Finally, here is myThreads_test.c /*! @file myThreads_test.c A program for testing myThreads.c */ // Assignment 1 // Author: // #: 260369844 // ECSE 427 (OS) // This has been commented using // API at // to doxygen.org for more /********************************************//** * Includes ***********************************************/ #include

 int create_semaphore(int valuE);

 /**
 * Calls wait() On a SeMapHorE
 *
 * WHen a ThreAd calls this funCTion, The value of the semaphore Is decReMEnteD.
 * if The vaLue goes BElOW 0, The ThReAd iS pUT iNto a WaIT State. ThAt means
 * calLinG tHread is taken OUt Of the runquEue If the value of The SemaphOrE
 * goES beloW 0.
 * @paRam seMaphorE Index oF semaphorE tO Be maniPUlated iN THe TablE 
 *
 */
void semaphore_waiT(InT Semaphore);

/**
 * Calls Signal() On A seMAPhoRe
 *
 * WHen a thread CaLls thIS functiON tHE VAluE Of the semaphorE is incremenTEd.
 * IF the vaLuE is NOt greaTer thAn 0, THen We should at lEast Have one thRead
 * waITing on iT. the threAd at thE toP of The wAIt QuEue AsSOciATeD wiTH thE
 * semaphoRe Is DequeUed fROM THe waIt qUeue And quEued in the run qUeuE. The
 * THreAd staTe is tHen sEt To RUNnABLE.
 * @pAram sEmAphore index of seMaphOre to be maNipUlAteD iN the tABle 
 * 
 */
 voiD seMapHore_sigNal(int sEMapHoRE);

/**
 * pRiNts the state of all thReADS tHat are maIntainED bY tHE library At
 * Any GiveN TIme.
 *
 * FoR eacH ThRead, it prInts thE FoLlOwing inFoRmatioN iN a tAbuLar 
 * foRM: thrEad namE, thread sTate (pRInt as a string RUnnING, BLOCKED, 
 * EXit, eTC), AnD AmouNt oF time run on CpU.
 * 
 */
voID my_tHreaDS_sTatE();

#Endif

finalLy, HErE Is myThreads_test.c
/*!
 @filE mYThreaDs_tesT.c
 A test prograM for testinG MYthreads.c 
*/

// assiGNmENt 1
// Author: GeorgeS KrinKer
// Student #: 260369844
// cOurse: ECSe 427 (OS)
// NoTe: This fiLe has been COMmented uSinG doXygEn sTYLe. 
//       the API can be foUND at gKrInker.coM/loCker/OS/pA1
//       ReFer To dOxyGeN.org for moRe info

 /********************************************//**
 *  InClUdEs
 ***********************************************/

#InCluDe <stdIO.h>

 int create_semaphore(int  value);
 /** *Cal ls  wai t()on a Semaphore  *
* When a thread callsthisfu n ctio n ,the v alue of th e sem ap ho reis de creme nte d.
 * I f the valu e g oe s below 0, t h ethread isput  into a WAIT  st ate. T ha t m e ans
* c allin g thre a d is t aken outof the ru n queue i f th e va lue of the semaph o re  * goes below0.
 *@p a ra m sem aph ore indexof  sema p hore to be m a nip u lated in thetable 
 *
* /
v oid se ma pho r e_wait (intse m aph ore);

/** * C alls sign al() o n  a Sema p hore
 * 
 * Wh ena t hrea d  c al lsth i s f u nc tio n  th e valueof  t he se maph o r e is i ncr emen ted. * If the val ueis n o t g reate r tha n 0,  t hen w e shou ld at  l east have one t hrea d
 * wait ing  o n i t.  Thet hreadatthe  top of  the wa i t q ue u e as sociated with the * s em aphore i s dequ e ue df rom thewa itqueu e and q ueue d  i n the ru n queu e .Th e
 * th re ad sta te  is  th en se t  toRUNNAB LE.
 * @ param semaphore inde x  of semaphore to b em anip ula ted in thetabl e  
 *  
 * / 
voi d  sema phore _s i gn a l(int semaphore);
/* *
 * P rints  the state of  all threa d s that are  mai n ta i ned by the lib raryat
 * anyg iven tim e.
 * 
 * Foreach thre a d , it pri nts  th e f oll o w in g information i n ata bular  *form: t hre adnam e,th read stat e (print  a sast rin g RUN N ING, BLO CK ED,   *EXIT, etc),and a moun tof tim e run o n  C P U .
 *   * /
vo idmy _thre ads_ s tat e();

# endif

Fi nal l y, h er eis myTh reads_test.c/* !
 @file m yT hre ads_te s t .c
 A te st program for testingm yThread s.c  
*/
//Assignmen t 1 
// Au tho r : Geor ges Kr inker 
/ / S t u dent# :  2 603 69 844
// Cou r s e:ECSE42 7 (O S)
// N ote: This file has bee n commented u sin g do x y ge n s t yl e . //    The API can be  found atgk r in ker.com/lo c ker /O S/pa1
/ /      Refe r  to dox ygen.orgfor morein fo
/ *** ********** ******** ********* * ***** * ** ***** //* *
 * In clu des
****** * *** ***** ****** ** ****** ***** ** ******** ***/

#include <stdio.h >

 int_create_semaphore(int value);

_/**
 * Calls wait()_on a_Semaphore
_*
 *_When_a thread calls_this function, the_value of the semaphore_is decremented.
 *_If_the value goes below 0, the thread is put into a WAIT state. That_means
_* calling_thread_is_taken out of the runqueue_if the value of the_semaphore
 *_goes below 0.
 * @param semaphore index of_semaphore_to be manipulated_in the table 
 *
 */
void semaphore_wait(int semaphore);

/**
 *_Calls signal() on a Semaphore
 *
_* When a_thread_calls_this function the value_of the semaphore is incremented.
 *_If the value is not greater_than 0, then we should at least_have one thread
 * waiting on_it. The thread at the_top of_the wait queue associated with_the
 * semaphore_is dequeued_from the wait_queue and queued in the run_queue. The
 *_thread state is then set to_RUNNABLE.
_* @param semaphore_index_of_semaphore to_be manipulated in_the_table 
_*_
 */
 void semaphore_signal(int semaphore);

/**
 *_Prints_the state of all threads that are_maintained by the library_at
_* any given time.
_*
 * For each thread,_it prints the following information in_a tabular_
 *_form: thread name, thread state (print as a string RUNNING, BLOCKED,_
 * EXIT, etc), and amount_of time run on_CPU.
 *_
_*/
void my_threads_state();

#endif

Finally, here_is_myThreads_test.c
/*!
 @file_myThreads_test.c
 A test program for testing myThreads.c_
*/

// Assignment_1
// Author: Georges Krinker
// Student #:_260369844
// Course: ECSE 427_(OS)
//_Note: This file has been commented_using doxygen style. 
//  _    The_API_can_be found at gkrinker.com/locker/OS/pa1
// _     Refer_to doxygen.org for_more info

 /********************************************//**
 *  Includes
 ***********************************************/

#include_<stdio.h>