Created
March 28, 2010 09:41
-
-
Save zoranzaric/346677 to your computer and use it in GitHub Desktop.
GDI3 Kram
This file contains hidden or 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
T - CPU-Zeit in Sekunden | |
f - Taktfrequenz in Zyklen pro Sekunde | |
t - Taktzykluszeit in Sekunden pro Zyklus | |
MIPS - Millionen von Instruktionen pro Sekunde | |
CPI - mittlere Anzahl Zyklen pro Instruktion | |
B - Anzahl Instruktionen | |
Z - CPU-Zeit in Zyklen | |
T = Z * t | |
CPI = Z / (T * MIPS * 10^6) | |
T = B * CPI / f | |
B = T * MIPS * 10^6 | |
Z = T * CPI * MIPS * 10^6 |
This file contains hidden or 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
Alle Priester saufen Tequila nach der Prädigt | |
7. Application | |
6. Presentation | |
5. Session | |
4. Transport | |
3. Network | |
2. Data | |
1. Physical |
This file contains hidden or 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
// Andrew S. Tanenbaum: Modern Operating Systems 3e p. 164 | |
#define N 5 | |
#define LEFT (i+N-1)%N | |
#define RIGHT (i+1)%N | |
#define THINKING 0 | |
#define HUNGRY 1 | |
#define EATING 2 | |
typedf int semaphore; | |
int state[N]; | |
semaphore mutex = 1; | |
semaphore s[N]; | |
void philosopher(int i) | |
{ | |
while (TRUE) { | |
think(); | |
take_forks(i); | |
eat(); | |
put_forks(i); | |
} | |
} | |
void take_forks(int i) | |
{ | |
down(&mutex); | |
state[i] = HUNGRY; | |
test(i); | |
up(&mutex); | |
down(&s[i]); | |
} | |
void put_forks(i) | |
{ | |
down(&mutes); | |
state[i] = THINKING; | |
test(LEFT); | |
test(RIGHT); | |
up(&mutex); | |
} | |
void test(i) | |
{ | |
if (state[i] == HUNGRY && state[LEFT] != EATING && state[RIGHT] != EATING) { | |
state[i] = EATING; | |
up(&s[i]); | |
} | |
} |
This file contains hidden or 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
josephus: | |
sub $sp, $sp, 12 | |
sw $ra, 8($sp) #sichere ruecksprungadresse | |
sw $a1, 4($sp) #sichere K | |
sw $a0, 0($sp) #sichere N | |
seq $t0, $a0, 1 | |
beqz $t0, rekursion #N ist != 1, also rekursion | |
li $v0, 0 | |
jr $ra | |
rekursion: | |
sub $a0, $a0, 1 #dekrementiere N um 1 | |
jal josephus | |
lw $a0, 0($sp) #hole N | |
lw $a1, 4($sp) #hole K | |
lw $ra, 8($sp) #hole ruecksprungadresse | |
add $sp, $sp, 12 |
This file contains hidden or 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
2^3 - 8 | |
2^4 - 16 | |
2^5 - 32 | |
2^6 - 64 | |
2^7 - 128 | |
2^8 - 256 | |
2^9 - 512 | |
2^10 - 1024 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment