forked from greggagne/OSC9e
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated with README files per chapter
- Loading branch information
Showing
14 changed files
with
208 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.DS_STORE | ||
a.out | ||
*.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The files | ||
|
||
file1.txt | ||
|
||
and | ||
|
||
file2.txt | ||
|
||
are associated with exercise 12.21 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Figure 17.4 DNSLookUp.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This contains the source code and Makefile for the programming | ||
project for creating a Linux kernel module. | ||
|
||
Refer to the project for instructions on building the module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Figure 3.9 newproc-posix.c | ||
Figure 3.11 newproc-win32.c | ||
Figure 3.17 shm-posix-consumer.c | ||
Figure 3.18 shm-posix-producer.c | ||
Figure 3.21 DateServer.java | ||
Figure 3.22 DateClient.java | ||
Figure 3.25/3.26 unix_pipe.c | ||
Figure 3.27 win32-pipe-parent.c | ||
Figure 3.29 win32-pipe-child.c | ||
Figure 3.30 fork-question-1.c | ||
Figure 3.31 fork-question-2.c | ||
Figure 3.36 simple-shell.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Figure 4.9 thrd-posix.c | ||
Figure 4.11 thrd-win32.c | ||
Figure 4.12 Driver.java | ||
OpenMP Example openmp.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
POSIX unnamed semaphores (Linux) posix-unnamed-sem.c | ||
POSIX named semaphores (OS X) posix-named-sem.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Example illustrating POSIX named semaphores | ||
* | ||
* Compilation (on OS X): | ||
* | ||
* gcc -lpthread posix-named-sem.c | ||
* | ||
* This example includes the appropriate error checking | ||
* that is not covered in the text. | ||
* | ||
* This program illustrates POSIX named semaphores which | ||
* work on OS X systems. | ||
* | ||
* Operating System Concepts - Ninth Edition | ||
* John Wiley & Sons - 2013. | ||
*/ | ||
|
||
#include <unistd.h> | ||
#include <sys/types.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <pthread.h> | ||
#include <string.h> | ||
#include <semaphore.h> | ||
|
||
int main(void) | ||
{ | ||
sem_t *sem; | ||
|
||
/** | ||
* Create a named semaphore called 'OSC' | ||
*/ | ||
|
||
// first remove the semaphore if it already exists | ||
if (sem_unlink("OSC") == -1) | ||
printf("Error removing %s\n",strerror(errno)); | ||
|
||
// create and initialize the semaphore | ||
if ( (sem = sem_open("OSC", O_CREAT, 0666, 1)) == SEM_FAILED) | ||
printf("Error creating %s\n",strerror(errno)); | ||
|
||
if (sem_wait(sem) != 0) | ||
printf("Error waiting %s\n",strerror(errno)); | ||
|
||
printf("*** Critical Section *** \n"); | ||
|
||
if (sem_post(sem) != 0) | ||
printf("Error posting %s\n",strerror(errno)); | ||
|
||
printf("*** Non-Critical Section *** \n"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Figure 6.8 posix-sched.c | ||
Figure 6.20 posix-rt.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Figure 7.4 deadlock.c | ||
|
||
This program illustrates deadlock - read through it to better understand | ||
how the program operates. Deadlock is not always possible and it depends | ||
upon how the threads are scheduled by the operating system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* A pthread program illustrating deadlock. | ||
* | ||
* Usage: | ||
* gcc deadlock.c -lpthread | ||
* ./a.out | ||
* | ||
* Figure 7.4 | ||
* | ||
* @author Gagne, Galvin, Silberschatz | ||
* Operating System Concepts - Ninth Edition | ||
* Copyright John Wiley & Sons - 2013. | ||
*/ | ||
|
||
#include <pthread.h> | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
|
||
pthread_mutex_t first_mutex; | ||
pthread_mutex_t second_mutex; | ||
|
||
void *do_work_one(void *param); | ||
void *do_work_two(void *param); | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
pthread_t tid1, tid2; /* the thread identifiers */ | ||
pthread_attr_t attr; /* set of attributes for the thread */ | ||
|
||
/* get the default attributes */ | ||
pthread_attr_init(&attr); | ||
|
||
/* create the mutex locks */ | ||
pthread_mutex_init(&first_mutex,NULL); | ||
pthread_mutex_init(&second_mutex,NULL); | ||
|
||
/* create the threads */ | ||
pthread_create(&tid1,&attr,do_work_one,NULL); | ||
pthread_create(&tid2,&attr,do_work_two,NULL); | ||
|
||
/* now wait for the thread to exit */ | ||
pthread_join(tid1,NULL); | ||
pthread_join(tid2,NULL); | ||
|
||
printf("Parent DONE\n"); | ||
|
||
/* destroy the mutex before exiting */ | ||
pthread_mutex_destroy(&first_mutex); | ||
pthread_mutex_destroy(&second_mutex); | ||
} | ||
|
||
/** | ||
* The first thread worker | ||
*/ | ||
void *do_work_one(void *param) | ||
{ | ||
pthread_mutex_lock(&first_mutex); | ||
printf("Worker 1 has acquired first mutex\n"); | ||
pthread_mutex_lock(&second_mutex); | ||
printf("Worker 1 has acquired second mutex\n"); | ||
|
||
/** | ||
* Do some work | ||
*/ | ||
|
||
printf("Worker 1 is whistling .....\n"); | ||
|
||
pthread_mutex_unlock(&second_mutex); | ||
pthread_mutex_unlock(&first_mutex); | ||
|
||
printf("worker 1 done\n"); | ||
|
||
pthread_exit(0); | ||
} | ||
|
||
/** | ||
* The second thread worker | ||
*/ | ||
void *do_work_two(void *param) | ||
{ | ||
pthread_mutex_lock(&second_mutex); | ||
printf("Worker 2 has acquired second mutex\n"); | ||
pthread_mutex_lock(&first_mutex); | ||
printf("Worker 2 has acquired first mutex\n"); | ||
|
||
/** | ||
* Do some work | ||
* | ||
*/ | ||
|
||
printf("Worker 2 is whistling .....\n"); | ||
|
||
pthread_mutex_unlock(&first_mutex); | ||
pthread_mutex_unlock(&second_mutex); | ||
|
||
pthread_exit(0); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
The following 3 files are related to virtual memory manager project: | ||
|
||
BACKING_STORE.bin | ||
addresses.txt | ||
correct.txt | ||
|
||
windows-programs (directory) | ||
|
||
README | ||
temp.txt | ||
Figure 9.25 consumer.c | ||
Figure 9.26 producer.c |