Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132929 views
License: OTHER
1
/* Example code for Think OS.
2
3
Copyright 2015 Allen Downey
4
License: Creative Commons Attribution-ShareAlike 3.0
5
6
*/
7
8
#include <stdio.h>
9
#include <stdlib.h>
10
#include <pthread.h>
11
#include "utils.h"
12
#include "mysem.h"
13
14
Semaphore *make_semaphore(int value)
15
{
16
Semaphore *semaphore = check_malloc(sizeof(Semaphore));
17
// initialize the fields here
18
return semaphore;
19
}
20
21
void semaphore_wait(Semaphore *semaphore)
22
{
23
// put your implementation here
24
}
25
26
void semaphore_signal(Semaphore *semaphore)
27
{
28
// put your implementation here
29
}
30
31