jekyll-theme-gaeblogx 0.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +63 -5
  3. data/assets/page/{4about.html → 4about.md} +0 -0
  4. metadata +2 -100
  5. data/assets/10.jpg +0 -0
  6. data/assets/AWS-Introduction-ec2.png +0 -0
  7. data/assets/Cache-Oblivious-Algorithms-FunnelSort.jpg +0 -0
  8. data/assets/Condition-Variables-fig1.png +0 -0
  9. data/assets/Dynamic-Compilation-adaptJVM.pdf +0 -0
  10. data/assets/Dynamic-Compilation-dyncomp.pdf +0 -0
  11. data/assets/Fibonacci-Heap-Fig3.png +0 -0
  12. data/assets/Fibonacci-Heap-Fig5.png +0 -0
  13. data/assets/Fibonacci-Heap-Fig6.png +0 -0
  14. data/assets/Fibonacci-Heap-Fig7.png +0 -0
  15. data/assets/File-System-bc.jpg +0 -0
  16. data/assets/File-System-filetable.rich.jpg +0 -0
  17. data/assets/GIL-Battle.png +0 -0
  18. data/assets/GIL-CPU.png +0 -0
  19. data/assets/GIL-Check.png +0 -0
  20. data/assets/GIL-IO.png +0 -0
  21. data/assets/GIL-Measure-1.png +0 -0
  22. data/assets/GIL-Measure-2.png +0 -0
  23. data/assets/GIL-Signal.png +0 -0
  24. data/assets/GIL-Tick.png +0 -0
  25. data/assets/Garbage-Collection-Slides-gc.pdf +0 -0
  26. data/assets/Garbage-Collection-copying-1.png +0 -0
  27. data/assets/Garbage-Collection-copying-2.png +0 -0
  28. data/assets/Garbage-Collection-free-list.png +0 -0
  29. data/assets/Garbage-Collection-generation-1.png +0 -0
  30. data/assets/Garbage-Collection-mark-sweep.png +0 -0
  31. data/assets/Garbage-Collection-nursery-1.png +0 -0
  32. data/assets/Garbage-Collection-nursery-2.png +0 -0
  33. data/assets/Garbage-Collection-nursery-3.png +0 -0
  34. data/assets/Garbage-Collection-nursery-4.png +0 -0
  35. data/assets/Garbage-Collection-nursery-5.png +0 -0
  36. data/assets/Garbage-Collection-process.png +0 -0
  37. data/assets/Garbage-Collection-ref-counting.png +0 -0
  38. data/assets/Interpreter-Optimization-interp.pdf +0 -0
  39. data/assets/Memory-Management-fig1.png +0 -0
  40. data/assets/Memory-Management-fig2.png +0 -0
  41. data/assets/Memory-Management-fig3.png +0 -0
  42. data/assets/Memory-Management-fig4.png +0 -0
  43. data/assets/Memory-Management-fig5.png +0 -0
  44. data/assets/Memory-Management-fig6.png +0 -0
  45. data/assets/Memory-Management-fig7.png +0 -0
  46. data/assets/Memory-Management-fig8.png +0 -0
  47. data/assets/Multicore-GIL-1.png +0 -0
  48. data/assets/Multicore-GIL-2.png +0 -0
  49. data/assets/My-Photo.JPG +0 -0
  50. data/assets/Operating-System-Virtualization-ept.png +0 -0
  51. data/assets/Operating-System-Virtualization-guest-page.png +0 -0
  52. data/assets/Operating-System-Virtualization-kvm-arch.png +0 -0
  53. data/assets/Operating-System-Virtualization-kvm-process.png +0 -0
  54. data/assets/Operating-System-Virtualization-kvm-qemu.png +0 -0
  55. data/assets/Operating-System-Virtualization-kvm-state.png +0 -0
  56. data/assets/Operating-System-Virtualization-vtx.png +0 -0
  57. data/assets/Operating-System-Virtualization-xen-arch.png +0 -0
  58. data/assets/Program-Profiling-profiling.pdf +0 -0
  59. data/assets/Programming-Language-Virtual-Machine-vm.pdf +0 -0
  60. data/assets/Remote-Shell-Session-Setup-1.png +0 -0
  61. data/assets/Signals-1.png +0 -0
  62. data/assets/Signals-2.png +0 -0
  63. data/assets/Signals-3.png +0 -0
  64. data/assets/Some-Slides-about-Containers-Kubernetes.pdf +0 -0
  65. data/assets/Some-Slides-about-Containers-UCSB-nurmi.pdf +0 -0
  66. data/assets/Some-Slides-about-PaaS-CS293B_CloudPlatforms.pdf +0 -0
  67. data/assets/avg-1thread.c +0 -172
  68. data/assets/avg-manythread.c +0 -284
  69. data/assets/avg-nothread.c +0 -71
  70. data/assets/file-create1.c +0 -75
  71. data/assets/file-create2.c +0 -120
  72. data/assets/file-fd1.c +0 -56
  73. data/assets/file-fd2.c +0 -25
  74. data/assets/file-fd3.c +0 -23
  75. data/assets/file-read1.c +0 -62
  76. data/assets/file-read2.c +0 -66
  77. data/assets/file-seek1.c +0 -87
  78. data/assets/fork-1.c +0 -35
  79. data/assets/fork-2.c +0 -44
  80. data/assets/fork-3.c +0 -60
  81. data/assets/fork-4.c +0 -64
  82. data/assets/joinall-1.c +0 -163
  83. data/assets/joinall-2.c +0 -162
  84. data/assets/market-kthreads.c +0 -465
  85. data/assets/market-semaphore.c +0 -504
  86. data/assets/market1.c +0 -478
  87. data/assets/market2.c +0 -490
  88. data/assets/market3.c +0 -503
  89. data/assets/market4.c +0 -509
  90. data/assets/my-cat.c +0 -35
  91. data/assets/pipe-1.c +0 -45
  92. data/assets/pipe-2.c +0 -80
  93. data/assets/pipe-3.c +0 -83
  94. data/assets/pipe-4.c +0 -116
  95. data/assets/race1.c +0 -75
  96. data/assets/race2.c +0 -77
  97. data/assets/race3.c +0 -87
  98. data/assets/race_ABC.c +0 -144
  99. data/assets/semaphore.book.ps +0 -8827
  100. data/assets/sys-call1.c +0 -20
  101. data/assets/sys-call2.c +0 -16
  102. data/assets//350/265/253/347/202/2161.PNG +0 -0
data/assets/market1.c DELETED
@@ -1,478 +0,0 @@
1
- /*
2
- * cs170 -- Rich Wolski
3
- * producer-consumer example
4
- * uses mutex locks only
5
- */
6
- #include <unistd.h>
7
- #include <stdlib.h>
8
- #include <stdio.h>
9
- #include <pthread.h>
10
- #include <string.h>
11
-
12
- #include "c-timer.h"
13
-
14
- #define RAND() (drand48())
15
-
16
- struct order
17
- {
18
- int stock_id;
19
- int quantity;
20
- int action; /* buy or sell */
21
- int fulfilled;
22
- };
23
-
24
- struct order_que
25
- {
26
- struct order **orders;
27
- int size;
28
- int head;
29
- int tail;
30
- pthread_mutex_t lock;
31
- };
32
-
33
- struct market
34
- {
35
- pthread_mutex_t lock;
36
- int *stocks;
37
- int count;
38
- };
39
-
40
- struct order *InitOrder(int id, int quantity, int action)
41
- {
42
- struct order *order;
43
-
44
- order = (struct order *)malloc(sizeof(struct order));
45
- if(order == NULL) {
46
- return(NULL);
47
- }
48
- order->stock_id = id;
49
- order->quantity = quantity;
50
- order->action = action;
51
- order->fulfilled = 0;
52
- return(order);
53
- }
54
-
55
- void FreeOrder(struct order *order)
56
- {
57
- free(order);
58
- }
59
-
60
- struct order_que *InitOrderQue(int size)
61
- {
62
- struct order_que *oq;
63
-
64
- oq = (struct order_que *)malloc(sizeof(struct order_que));
65
- if(oq == NULL) {
66
- return(NULL);
67
- }
68
- memset(oq,0,sizeof(struct order_que));
69
-
70
- oq->size = size+1; /* empty condition burns a slot */
71
- oq->orders = (struct order **)malloc(oq->size*sizeof(struct order *));
72
- if(oq->orders == NULL) {
73
- free(oq);
74
- return(NULL);
75
- }
76
- memset(oq->orders,0,size*sizeof(struct order *));
77
-
78
- pthread_mutex_init(&oq->lock,NULL);
79
-
80
- return(oq);
81
- }
82
-
83
- void FreeOrderQue(struct order_que *oq)
84
- {
85
- while(oq->head != oq->tail) {
86
- FreeOrder(oq->orders[oq->tail]);
87
- oq->tail = (oq->tail + 1) % oq->size;
88
- }
89
-
90
- free(oq->orders);
91
- free(oq);
92
- return;
93
- }
94
-
95
- struct market *InitMarket(int stock_count, int init_quantity)
96
- {
97
- struct market *m;
98
- int i;
99
-
100
- m = (struct market *)malloc(sizeof(struct market));
101
- if(m == NULL) {
102
- return(NULL);
103
- }
104
- m->count = stock_count;
105
-
106
- m->stocks = (int *)malloc(stock_count*sizeof(int));
107
- if(m->stocks == NULL) {
108
- free(m);
109
- return(NULL);
110
- }
111
-
112
- for(i=0; i < stock_count; i++) {
113
- m->stocks[i] = init_quantity;
114
- }
115
-
116
- pthread_mutex_init(&m->lock,NULL);
117
-
118
- return(m);
119
- }
120
-
121
- void FreeMarket(struct market *m)
122
- {
123
- free(m->stocks);
124
- free(m);
125
- return;
126
- }
127
-
128
- void PrintMarket(struct market *m)
129
- {
130
- int i;
131
- for(i=0; i < m->count; i++) {
132
- printf("stock: %d, quantity: %d\n",
133
- i,m->stocks[i]);
134
- }
135
-
136
- return;
137
- }
138
-
139
- struct client_arg
140
- {
141
- int id;
142
- int order_count;
143
- struct order_que *order_que;
144
- int max_stock_id;
145
- int max_quantity;
146
- int verbose;
147
- };
148
-
149
- struct trader_arg
150
- {
151
- int id;
152
- struct order_que *order_que;
153
- struct market *market;
154
- int *done;
155
- int verbose;
156
- };
157
-
158
- void *ClientThread(void *arg)
159
- {
160
- struct client_arg *ca = (struct client_arg *)arg;
161
- int i;
162
- int next;
163
- struct order *order;
164
- int stock_id;
165
- int quantity;
166
- int action;
167
- int queued;
168
- double now;
169
-
170
-
171
- for(i=0; i < ca->order_count; i++) {
172
- /*
173
- * create an order for a random stock
174
- */
175
- stock_id = (int)(RAND() * ca->max_stock_id);
176
- quantity = (int)(RAND() * ca->max_quantity);
177
- if(RAND() > 0.5) {
178
- action = 0; /* 0 => buy */
179
- } else {
180
- action = 1; /* 1 => sell */
181
- }
182
- order = InitOrder(stock_id,quantity,action);
183
- if(order == NULL) {
184
- fprintf(stderr,"no space for order\n");
185
- exit(1);
186
- }
187
- /*
188
- * queue it for the traders
189
- */
190
- queued = 0;
191
- while(queued == 0) {
192
- pthread_mutex_lock(&(ca->order_que->lock));
193
- next = (ca->order_que->head + 1) % ca->order_que->size;
194
- /*
195
- * is the queue full?
196
- */
197
- if(next == ca->order_que->tail) {
198
- pthread_mutex_unlock(&(ca->order_que->lock));
199
- continue;
200
- }
201
- /*
202
- * there is space in the queue, add the order and bump
203
- * the head
204
- */
205
- if(ca->verbose == 1) {
206
- now = CTimer();
207
- printf("%10.0f client %d: ",now,ca->id);
208
- printf("queued stock %d, for %d, %s\n",
209
- order->stock_id,
210
- order->quantity,
211
- (order->action ? "SELL" : "BUY"));
212
- }
213
- ca->order_que->orders[next] = order;
214
- ca->order_que->head = next;
215
- queued = 1;
216
- pthread_mutex_unlock(&(ca->order_que->lock));
217
-
218
- /*
219
- * spin waiting until the order is fulfilled
220
- */
221
- while(order->fulfilled == 0);
222
- /*
223
- * done, free the order and repeat
224
- */
225
- FreeOrder(order);
226
- }
227
- }
228
-
229
- return(NULL);
230
- }
231
-
232
- void *TraderThread(void *arg)
233
- {
234
- struct trader_arg *ta = (struct trader_arg *)arg;
235
- int dequeued;
236
- struct order *order;
237
- int tail;
238
- double now;
239
- int next;
240
-
241
- while(1) {
242
- dequeued = 0;
243
- while(dequeued == 0) {
244
- pthread_mutex_lock(&(ta->order_que->lock));
245
- /*
246
- * is the queue empty?
247
- */
248
- if(ta->order_que->head == ta->order_que->tail) {
249
- pthread_mutex_unlock(&(ta->order_que->lock));
250
- /*
251
- * if the queue is empty, are we done?
252
- */
253
- if(*(ta->done) == 1) {
254
- pthread_exit(NULL);
255
- }
256
- continue;
257
- }
258
- /*
259
- * get the next order
260
- */
261
- next = (ta->order_que->tail + 1) % ta->order_que->size;
262
- order = ta->order_que->orders[next];
263
- ta->order_que->tail = next;
264
- pthread_mutex_unlock(&(ta->order_que->lock));
265
- dequeued = 1;
266
- }
267
- /*
268
- * have an order to process
269
- */
270
- pthread_mutex_lock(&(ta->market->lock));
271
- if(order->action == 1) { /* BUY */
272
- ta->market->stocks[order->stock_id] -= order->quantity;
273
- if(ta->market->stocks[order->stock_id] < 0) {
274
- ta->market->stocks[order->stock_id] = 0;
275
- }
276
- } else {
277
- ta->market->stocks[order->stock_id] += order->quantity;
278
- }
279
- pthread_mutex_unlock(&(ta->market->lock));
280
- if(ta->verbose == 1) {
281
- now = CTimer();
282
- printf("%10.0f trader: %d ",now,ta->id);
283
- printf("fulfilled stock %d for %d\n",
284
- order->stock_id,
285
- order->quantity);
286
- }
287
- /*
288
- * tell the client the order is done
289
- */
290
- order->fulfilled = 1;
291
- }
292
-
293
- return(NULL);
294
- }
295
-
296
- #define ARGS "c:t:o:q:s:V"
297
- char *Usage = "market1 -c clients -t traders -o orders -q queue-size -s stock-count -V <verbose on>\n";
298
-
299
- #define INIT_COUNT 5000
300
-
301
- int main(int argc, char **argv)
302
- {
303
- int c;
304
- int client_threads;
305
- int trader_threads;
306
- int orders_per_client;
307
- int que_size;
308
- int max_stock;
309
- int verbose;
310
- struct client_arg *ca;
311
- struct trader_arg *ta;
312
- pthread_t *client_ids;
313
- pthread_t *trader_ids;
314
- struct order_que *order_que;
315
- struct market *market;
316
- int i;
317
- int done;
318
- int err;
319
- double start;
320
- double end;
321
-
322
-
323
- /*
324
- * defaults
325
- */
326
- client_threads = 1;
327
- trader_threads = 1;
328
- orders_per_client = 1;
329
- verbose = 0;
330
- que_size = 1;
331
- max_stock = 1;
332
-
333
- while((c = getopt(argc,argv,ARGS)) != EOF) {
334
- switch(c) {
335
- case 'c':
336
- client_threads = atoi(optarg);
337
- break;
338
- case 't':
339
- trader_threads = atoi(optarg);
340
- break;
341
- case 'o':
342
- orders_per_client = atoi(optarg);
343
- break;
344
- case 'q':
345
- que_size = atoi(optarg);
346
- break;
347
- case 's':
348
- max_stock = atoi(optarg);
349
- break;
350
- case 'V':
351
- verbose = 1;
352
- break;
353
- default:
354
- fprintf(stderr,
355
- "unrecognized command %c\n",
356
- (char)c);
357
- fprintf(stderr,"usage: %s",Usage);
358
- exit(1);
359
- }
360
- }
361
-
362
- client_ids = (pthread_t *)malloc(client_threads*sizeof(pthread_t));
363
- if(client_ids == NULL) {
364
- exit(1);
365
- }
366
-
367
- ca = (struct client_arg *)malloc(client_threads*sizeof(struct client_arg));
368
- if(ca == NULL) {
369
- exit(1);
370
- }
371
-
372
- trader_ids = (pthread_t *)malloc(trader_threads*sizeof(pthread_t));
373
- if(trader_ids == NULL) {
374
- exit(1);
375
- }
376
-
377
- ta = (struct trader_arg *)malloc(trader_threads*sizeof(struct trader_arg));
378
- if(ta == NULL) {
379
- exit(1);
380
- }
381
-
382
- order_que = InitOrderQue(que_size);
383
- if(order_que == NULL) {
384
- exit(1);
385
- }
386
-
387
- market = InitMarket(max_stock,INIT_COUNT);
388
- if(market == NULL) {
389
- exit(1);
390
- }
391
-
392
- start = CTimer();
393
- for(i=0; i < client_threads; i++) {
394
- ca[i].id = i;
395
- ca[i].order_count = orders_per_client;
396
- ca[i].max_stock_id = max_stock;
397
- ca[i].max_quantity = INIT_COUNT;
398
- ca[i].order_que = order_que;
399
- ca[i].verbose = verbose;
400
- err = pthread_create(&client_ids[i],NULL,
401
- ClientThread,(void *)&ca[i]);
402
- if(err != 0) {
403
- fprintf(stderr,"client thread create %d failed\n",i);
404
- exit(1);
405
- }
406
- }
407
-
408
- done = 0;
409
- for(i=0; i < trader_threads; i++) {
410
- ta[i].id = i;
411
- ta[i].order_que = order_que;
412
- ta[i].market = market;
413
- ta[i].done = &done;
414
- ta[i].verbose = verbose;
415
- err = pthread_create(&trader_ids[i],NULL,
416
- TraderThread,(void *)&ta[i]);
417
- if(err != 0) {
418
- fprintf(stderr,"trader thread create %d failed\n",i);
419
- exit(1);
420
- }
421
- }
422
-
423
- /*
424
- * wait for the clients to finish
425
- */
426
- for(i=0; i < client_threads; i++) {
427
- err = pthread_join(client_ids[i],NULL);
428
- if(err != 0) {
429
- fprintf(stderr,"client join %d failed\n",i);
430
- exit(1);
431
- }
432
- }
433
-
434
- /*
435
- * tell the traders we are done
436
- */
437
- done = 1;
438
-
439
- for(i=0; i < trader_threads; i++) {
440
- err = pthread_join(trader_ids[i],NULL);
441
- if(err != 0) {
442
- fprintf(stderr,"trader join %d failed\n",i);
443
- exit(1);
444
- }
445
- }
446
- end = CTimer();
447
-
448
- if(verbose == 1) {
449
- PrintMarket(market);
450
- }
451
-
452
- printf("%f transactions / sec\n",
453
- (double)(orders_per_client*client_threads) / (end-start));
454
-
455
- free(ca);
456
- free(ta);
457
- free(client_ids);
458
- free(trader_ids);
459
- FreeMarket(market);
460
- FreeOrderQue(order_que);
461
-
462
- return(0);
463
- }
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-