jekyll-theme-gaeblogx 0.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +63 -5
- data/assets/page/{4about.html → 4about.md} +0 -0
- metadata +2 -100
- data/assets/10.jpg +0 -0
- data/assets/AWS-Introduction-ec2.png +0 -0
- data/assets/Cache-Oblivious-Algorithms-FunnelSort.jpg +0 -0
- data/assets/Condition-Variables-fig1.png +0 -0
- data/assets/Dynamic-Compilation-adaptJVM.pdf +0 -0
- data/assets/Dynamic-Compilation-dyncomp.pdf +0 -0
- data/assets/Fibonacci-Heap-Fig3.png +0 -0
- data/assets/Fibonacci-Heap-Fig5.png +0 -0
- data/assets/Fibonacci-Heap-Fig6.png +0 -0
- data/assets/Fibonacci-Heap-Fig7.png +0 -0
- data/assets/File-System-bc.jpg +0 -0
- data/assets/File-System-filetable.rich.jpg +0 -0
- data/assets/GIL-Battle.png +0 -0
- data/assets/GIL-CPU.png +0 -0
- data/assets/GIL-Check.png +0 -0
- data/assets/GIL-IO.png +0 -0
- data/assets/GIL-Measure-1.png +0 -0
- data/assets/GIL-Measure-2.png +0 -0
- data/assets/GIL-Signal.png +0 -0
- data/assets/GIL-Tick.png +0 -0
- data/assets/Garbage-Collection-Slides-gc.pdf +0 -0
- data/assets/Garbage-Collection-copying-1.png +0 -0
- data/assets/Garbage-Collection-copying-2.png +0 -0
- data/assets/Garbage-Collection-free-list.png +0 -0
- data/assets/Garbage-Collection-generation-1.png +0 -0
- data/assets/Garbage-Collection-mark-sweep.png +0 -0
- data/assets/Garbage-Collection-nursery-1.png +0 -0
- data/assets/Garbage-Collection-nursery-2.png +0 -0
- data/assets/Garbage-Collection-nursery-3.png +0 -0
- data/assets/Garbage-Collection-nursery-4.png +0 -0
- data/assets/Garbage-Collection-nursery-5.png +0 -0
- data/assets/Garbage-Collection-process.png +0 -0
- data/assets/Garbage-Collection-ref-counting.png +0 -0
- data/assets/Interpreter-Optimization-interp.pdf +0 -0
- data/assets/Memory-Management-fig1.png +0 -0
- data/assets/Memory-Management-fig2.png +0 -0
- data/assets/Memory-Management-fig3.png +0 -0
- data/assets/Memory-Management-fig4.png +0 -0
- data/assets/Memory-Management-fig5.png +0 -0
- data/assets/Memory-Management-fig6.png +0 -0
- data/assets/Memory-Management-fig7.png +0 -0
- data/assets/Memory-Management-fig8.png +0 -0
- data/assets/Multicore-GIL-1.png +0 -0
- data/assets/Multicore-GIL-2.png +0 -0
- data/assets/My-Photo.JPG +0 -0
- data/assets/Operating-System-Virtualization-ept.png +0 -0
- data/assets/Operating-System-Virtualization-guest-page.png +0 -0
- data/assets/Operating-System-Virtualization-kvm-arch.png +0 -0
- data/assets/Operating-System-Virtualization-kvm-process.png +0 -0
- data/assets/Operating-System-Virtualization-kvm-qemu.png +0 -0
- data/assets/Operating-System-Virtualization-kvm-state.png +0 -0
- data/assets/Operating-System-Virtualization-vtx.png +0 -0
- data/assets/Operating-System-Virtualization-xen-arch.png +0 -0
- data/assets/Program-Profiling-profiling.pdf +0 -0
- data/assets/Programming-Language-Virtual-Machine-vm.pdf +0 -0
- data/assets/Remote-Shell-Session-Setup-1.png +0 -0
- data/assets/Signals-1.png +0 -0
- data/assets/Signals-2.png +0 -0
- data/assets/Signals-3.png +0 -0
- data/assets/Some-Slides-about-Containers-Kubernetes.pdf +0 -0
- data/assets/Some-Slides-about-Containers-UCSB-nurmi.pdf +0 -0
- data/assets/Some-Slides-about-PaaS-CS293B_CloudPlatforms.pdf +0 -0
- data/assets/avg-1thread.c +0 -172
- data/assets/avg-manythread.c +0 -284
- data/assets/avg-nothread.c +0 -71
- data/assets/file-create1.c +0 -75
- data/assets/file-create2.c +0 -120
- data/assets/file-fd1.c +0 -56
- data/assets/file-fd2.c +0 -25
- data/assets/file-fd3.c +0 -23
- data/assets/file-read1.c +0 -62
- data/assets/file-read2.c +0 -66
- data/assets/file-seek1.c +0 -87
- data/assets/fork-1.c +0 -35
- data/assets/fork-2.c +0 -44
- data/assets/fork-3.c +0 -60
- data/assets/fork-4.c +0 -64
- data/assets/joinall-1.c +0 -163
- data/assets/joinall-2.c +0 -162
- data/assets/market-kthreads.c +0 -465
- data/assets/market-semaphore.c +0 -504
- data/assets/market1.c +0 -478
- data/assets/market2.c +0 -490
- data/assets/market3.c +0 -503
- data/assets/market4.c +0 -509
- data/assets/my-cat.c +0 -35
- data/assets/pipe-1.c +0 -45
- data/assets/pipe-2.c +0 -80
- data/assets/pipe-3.c +0 -83
- data/assets/pipe-4.c +0 -116
- data/assets/race1.c +0 -75
- data/assets/race2.c +0 -77
- data/assets/race3.c +0 -87
- data/assets/race_ABC.c +0 -144
- data/assets/semaphore.book.ps +0 -8827
- data/assets/sys-call1.c +0 -20
- data/assets/sys-call2.c +0 -16
- data/assets//350/265/253/347/202/2161.PNG +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9537e69b0f238026029cf9fcf0d821397b3ce5b4
|
|
4
|
+
data.tar.gz: bb5701b87d62c89f0190e5bb1810091252a3c7c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d93c83aa79ea8d6a4d25be0dc9ec137c966e7a89fe5597f95284d0fe14ba1afb9422aa4c5fb1b3f80aa70b7f2401984509820345ce7dac648ae20cfdd9ae64f
|
|
7
|
+
data.tar.gz: 0bc1241ca32bd9e5e9c58f2675f4a81c6dd0483210dcbb3f1a32b9e1aa95f64e47c4f6e397041f686059c57024079cacdb9470d918f5e0fa2af528c868ef56be
|
data/README.md
CHANGED
|
@@ -1,9 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Jekyll Theme GaeBlogx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Credits: https://github.com/Gaohaoyang/gaohaoyang.github.io
|
|
4
|
+
|
|
5
|
+
Major features
|
|
4
6
|
|
|
5
7
|
Modifications:
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
+
- Categories, Tags, Archives
|
|
9
|
+
- Site-wide search provided by Algolia and Simple Jekyll Search
|
|
10
|
+
- Clean responsive design
|
|
11
|
+
- Disqus Comments and Google Analytics support
|
|
12
|
+
- SEO best practices via Jekyll SEO Tag
|
|
8
13
|
- Archive by month instead of year
|
|
9
|
-
-
|
|
14
|
+
- About page layout
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
If you're running Jekyll v3.5+ and self-hosting you can quickly install the
|
|
19
|
+
theme as a Ruby gem. If you're hosting with GitHub Pages you can install as a
|
|
20
|
+
remote theme or directly copy all of the theme files (see [structure](#structure)
|
|
21
|
+
below) into your project.
|
|
22
|
+
|
|
23
|
+
First have a `index.html` in your root folder, containing:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
---
|
|
27
|
+
layout: home
|
|
28
|
+
paginate: true
|
|
29
|
+
---
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
then:
|
|
33
|
+
|
|
34
|
+
### Ruby Gem Method
|
|
35
|
+
|
|
36
|
+
1. Add this line to your Jekyll site's `Gemfile`:
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
gem "jekyll-theme-gaeblogx"
|
|
40
|
+
```
|
|
41
|
+
2. Add this line to your Jekyll site's `_config.yml` file:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
theme: jekyll-theme-gaeblogx
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
2. Then run [Bundler](http://bundler.io/) to install the theme gem and dependencies:
|
|
48
|
+
|
|
49
|
+
```terminal
|
|
50
|
+
bundle install
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### GitHub Pages Method
|
|
54
|
+
|
|
55
|
+
GitHub Pages has added [full support](https://github.com/blog/2464-use-any-theme-with-github-pages)
|
|
56
|
+
for any GitHub-hosted theme.
|
|
57
|
+
|
|
58
|
+
1. Replace `gem "jekyll"` with:
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
gem "github-pages", group: :jekyll_plugins
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. Run `bundle update` and verify that all gems install properly.
|
|
65
|
+
|
|
66
|
+
3. Add `remote_theme: "SeraphRoy/GaeBlogx"` to your
|
|
67
|
+
`_config.yml` file. Remove any other `theme:` or `remote_theme:` entries.
|
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-theme-gaeblogx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Baby Pepper
|
|
@@ -130,86 +130,7 @@ files:
|
|
|
130
130
|
- _sass/_reset.scss
|
|
131
131
|
- _sass/_scrollbar.scss
|
|
132
132
|
- _sass/_syntax-highlighting.scss
|
|
133
|
-
- assets/10.jpg
|
|
134
|
-
- assets/AWS-Introduction-ec2.png
|
|
135
|
-
- assets/Cache-Oblivious-Algorithms-FunnelSort.jpg
|
|
136
|
-
- assets/Condition-Variables-fig1.png
|
|
137
|
-
- assets/Dynamic-Compilation-adaptJVM.pdf
|
|
138
|
-
- assets/Dynamic-Compilation-dyncomp.pdf
|
|
139
|
-
- assets/Fibonacci-Heap-Fig3.png
|
|
140
|
-
- assets/Fibonacci-Heap-Fig5.png
|
|
141
|
-
- assets/Fibonacci-Heap-Fig6.png
|
|
142
|
-
- assets/Fibonacci-Heap-Fig7.png
|
|
143
|
-
- assets/File-System-bc.jpg
|
|
144
|
-
- assets/File-System-filetable.rich.jpg
|
|
145
|
-
- assets/GIL-Battle.png
|
|
146
|
-
- assets/GIL-CPU.png
|
|
147
|
-
- assets/GIL-Check.png
|
|
148
|
-
- assets/GIL-IO.png
|
|
149
|
-
- assets/GIL-Measure-1.png
|
|
150
|
-
- assets/GIL-Measure-2.png
|
|
151
|
-
- assets/GIL-Signal.png
|
|
152
|
-
- assets/GIL-Tick.png
|
|
153
|
-
- assets/Garbage-Collection-Slides-gc.pdf
|
|
154
|
-
- assets/Garbage-Collection-copying-1.png
|
|
155
|
-
- assets/Garbage-Collection-copying-2.png
|
|
156
|
-
- assets/Garbage-Collection-free-list.png
|
|
157
|
-
- assets/Garbage-Collection-generation-1.png
|
|
158
|
-
- assets/Garbage-Collection-mark-sweep.png
|
|
159
|
-
- assets/Garbage-Collection-nursery-1.png
|
|
160
|
-
- assets/Garbage-Collection-nursery-2.png
|
|
161
|
-
- assets/Garbage-Collection-nursery-3.png
|
|
162
|
-
- assets/Garbage-Collection-nursery-4.png
|
|
163
|
-
- assets/Garbage-Collection-nursery-5.png
|
|
164
|
-
- assets/Garbage-Collection-process.png
|
|
165
|
-
- assets/Garbage-Collection-ref-counting.png
|
|
166
|
-
- assets/Interpreter-Optimization-interp.pdf
|
|
167
|
-
- assets/Memory-Management-fig1.png
|
|
168
|
-
- assets/Memory-Management-fig2.png
|
|
169
|
-
- assets/Memory-Management-fig3.png
|
|
170
|
-
- assets/Memory-Management-fig4.png
|
|
171
|
-
- assets/Memory-Management-fig5.png
|
|
172
|
-
- assets/Memory-Management-fig6.png
|
|
173
|
-
- assets/Memory-Management-fig7.png
|
|
174
|
-
- assets/Memory-Management-fig8.png
|
|
175
|
-
- assets/Multicore-GIL-1.png
|
|
176
|
-
- assets/Multicore-GIL-2.png
|
|
177
|
-
- assets/My-Photo.JPG
|
|
178
|
-
- assets/Operating-System-Virtualization-ept.png
|
|
179
|
-
- assets/Operating-System-Virtualization-guest-page.png
|
|
180
|
-
- assets/Operating-System-Virtualization-kvm-arch.png
|
|
181
|
-
- assets/Operating-System-Virtualization-kvm-process.png
|
|
182
|
-
- assets/Operating-System-Virtualization-kvm-qemu.png
|
|
183
|
-
- assets/Operating-System-Virtualization-kvm-state.png
|
|
184
|
-
- assets/Operating-System-Virtualization-vtx.png
|
|
185
|
-
- assets/Operating-System-Virtualization-xen-arch.png
|
|
186
|
-
- assets/Program-Profiling-profiling.pdf
|
|
187
|
-
- assets/Programming-Language-Virtual-Machine-vm.pdf
|
|
188
|
-
- assets/Remote-Shell-Session-Setup-1.png
|
|
189
|
-
- assets/Signals-1.png
|
|
190
|
-
- assets/Signals-2.png
|
|
191
|
-
- assets/Signals-3.png
|
|
192
|
-
- assets/Some-Slides-about-Containers-Kubernetes.pdf
|
|
193
|
-
- assets/Some-Slides-about-Containers-UCSB-nurmi.pdf
|
|
194
|
-
- assets/Some-Slides-about-PaaS-CS293B_CloudPlatforms.pdf
|
|
195
|
-
- assets/avg-1thread.c
|
|
196
|
-
- assets/avg-manythread.c
|
|
197
|
-
- assets/avg-nothread.c
|
|
198
133
|
- assets/feed.xml
|
|
199
|
-
- assets/file-create1.c
|
|
200
|
-
- assets/file-create2.c
|
|
201
|
-
- assets/file-fd1.c
|
|
202
|
-
- assets/file-fd2.c
|
|
203
|
-
- assets/file-fd3.c
|
|
204
|
-
- assets/file-read1.c
|
|
205
|
-
- assets/file-read2.c
|
|
206
|
-
- assets/file-seek1.c
|
|
207
|
-
- assets/fork-1.c
|
|
208
|
-
- assets/fork-2.c
|
|
209
|
-
- assets/fork-3.c
|
|
210
|
-
- assets/fork-4.c
|
|
211
|
-
- assets/joinall-1.c
|
|
212
|
-
- assets/joinall-2.c
|
|
213
134
|
- assets/js/jekyll-search.min.js
|
|
214
135
|
- assets/js/lunr.min.js
|
|
215
136
|
- assets/js/main.js
|
|
@@ -218,33 +139,14 @@ files:
|
|
|
218
139
|
- assets/js/search.js
|
|
219
140
|
- assets/js/smooth-scroll.min.js
|
|
220
141
|
- assets/js/waterfall.js
|
|
221
|
-
- assets/market-kthreads.c
|
|
222
|
-
- assets/market-semaphore.c
|
|
223
|
-
- assets/market1.c
|
|
224
|
-
- assets/market2.c
|
|
225
|
-
- assets/market3.c
|
|
226
|
-
- assets/market4.c
|
|
227
|
-
- assets/my-cat.c
|
|
228
142
|
- assets/page/0archives.html
|
|
229
143
|
- assets/page/1category.html
|
|
230
144
|
- assets/page/2tags.html
|
|
231
145
|
- assets/page/3search.html
|
|
232
|
-
- assets/page/4about.
|
|
233
|
-
- assets/pipe-1.c
|
|
234
|
-
- assets/pipe-2.c
|
|
235
|
-
- assets/pipe-3.c
|
|
236
|
-
- assets/pipe-4.c
|
|
237
|
-
- assets/race1.c
|
|
238
|
-
- assets/race2.c
|
|
239
|
-
- assets/race3.c
|
|
240
|
-
- assets/race_ABC.c
|
|
146
|
+
- assets/page/4about.md
|
|
241
147
|
- assets/search-by-algolia.svg
|
|
242
148
|
- assets/search_data.json
|
|
243
|
-
- assets/semaphore.book.ps
|
|
244
149
|
- assets/stylesheets/main.scss
|
|
245
|
-
- assets/sys-call1.c
|
|
246
|
-
- assets/sys-call2.c
|
|
247
|
-
- assets/赫炎1.PNG
|
|
248
150
|
homepage: https://github.com/SeraphRoy/GaeBlogx
|
|
249
151
|
licenses:
|
|
250
152
|
- MIT
|
data/assets/10.jpg
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/assets/File-System-bc.jpg
DELETED
|
Binary file
|
|
Binary file
|
data/assets/GIL-Battle.png
DELETED
|
Binary file
|
data/assets/GIL-CPU.png
DELETED
|
Binary file
|
data/assets/GIL-Check.png
DELETED
|
Binary file
|
data/assets/GIL-IO.png
DELETED
|
Binary file
|
data/assets/GIL-Measure-1.png
DELETED
|
Binary file
|
data/assets/GIL-Measure-2.png
DELETED
|
Binary file
|
data/assets/GIL-Signal.png
DELETED
|
Binary file
|
data/assets/GIL-Tick.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/assets/Multicore-GIL-1.png
DELETED
|
Binary file
|
data/assets/Multicore-GIL-2.png
DELETED
|
Binary file
|
data/assets/My-Photo.JPG
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/assets/Signals-1.png
DELETED
|
Binary file
|
data/assets/Signals-2.png
DELETED
|
Binary file
|
data/assets/Signals-3.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/assets/avg-1thread.c
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
#include <unistd.h>
|
|
2
|
-
#include <stdlib.h>
|
|
3
|
-
#include <stdio.h>
|
|
4
|
-
|
|
5
|
-
#include <pthread.h>
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* program to find the average value of a set of random numbers
|
|
9
|
-
* which forks off a single thread to do the sum computation
|
|
10
|
-
*
|
|
11
|
-
* usage: avg-1thread count
|
|
12
|
-
*
|
|
13
|
-
* where count is the number of random values to generate
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
char *Usage = "usage: avg-1thread count";
|
|
17
|
-
|
|
18
|
-
#define RAND() (drand48()) /* basic Linux random number generator */
|
|
19
|
-
|
|
20
|
-
/*
|
|
21
|
-
* data type definition for arguments passed to thread
|
|
22
|
-
*/
|
|
23
|
-
struct arg_struct
|
|
24
|
-
{
|
|
25
|
-
int size;
|
|
26
|
-
double *data;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
* data type definition for results passed back from threads
|
|
31
|
-
*/
|
|
32
|
-
struct result_struct
|
|
33
|
-
{
|
|
34
|
-
double sum;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
void *SumThread(void *arg)
|
|
38
|
-
{
|
|
39
|
-
int i;
|
|
40
|
-
double my_sum;
|
|
41
|
-
struct arg_struct *my_args;
|
|
42
|
-
int my_size;
|
|
43
|
-
double *my_data;
|
|
44
|
-
struct result_struct *result;
|
|
45
|
-
|
|
46
|
-
printf("sum thread running\n");
|
|
47
|
-
fflush(stdout);
|
|
48
|
-
|
|
49
|
-
my_args = (struct arg_struct *)arg;
|
|
50
|
-
result = (struct result_struct *)malloc(sizeof(struct result_struct));
|
|
51
|
-
if(result == NULL) {
|
|
52
|
-
exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
my_size = my_args->size;
|
|
56
|
-
my_data = my_args->data;
|
|
57
|
-
|
|
58
|
-
/*
|
|
59
|
-
* free the arg structure since it isn't needed any more
|
|
60
|
-
*/
|
|
61
|
-
free(my_args);
|
|
62
|
-
|
|
63
|
-
my_sum = 0.0;
|
|
64
|
-
for(i=0; i < my_size; i++) {
|
|
65
|
-
my_sum += my_data[i];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
result->sum = my_sum;
|
|
69
|
-
printf("sum thread done, returning\n");
|
|
70
|
-
fflush(stdout);
|
|
71
|
-
|
|
72
|
-
return((void *)result);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
int main(int argc, char **argv)
|
|
76
|
-
{
|
|
77
|
-
int i;
|
|
78
|
-
int n;
|
|
79
|
-
double *data;
|
|
80
|
-
int count;
|
|
81
|
-
struct arg_struct *args;
|
|
82
|
-
pthread_t thread_id;
|
|
83
|
-
struct result_struct *result;
|
|
84
|
-
int err;
|
|
85
|
-
|
|
86
|
-
/*
|
|
87
|
-
* santity check the arguments
|
|
88
|
-
*/
|
|
89
|
-
if(argc <= 1) {
|
|
90
|
-
fprintf(stderr,"must specify count\n");
|
|
91
|
-
fprintf(stderr,"%s",Usage);
|
|
92
|
-
exit(1);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
count = atoi(argv[1]); /* count is first argument */
|
|
96
|
-
|
|
97
|
-
if(count <= 0) {
|
|
98
|
-
fprintf(stderr,"invalid count %d\n",count);
|
|
99
|
-
exit(1);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/*
|
|
103
|
-
* make an array large enough to hold #count# doubles
|
|
104
|
-
*/
|
|
105
|
-
data = (double *)malloc(count * sizeof(double));
|
|
106
|
-
if(data == NULL) {
|
|
107
|
-
exit(1);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
* pick a bunch of random numbers
|
|
112
|
-
*/
|
|
113
|
-
for(i=0; i < count; i++) {
|
|
114
|
-
data[i] = RAND();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/*
|
|
118
|
-
* make a argument structure to use to pass the arguments to the
|
|
119
|
-
* thread
|
|
120
|
-
*/
|
|
121
|
-
args = (struct arg_struct *)malloc(sizeof(struct arg_struct));
|
|
122
|
-
if(args == NULL) {
|
|
123
|
-
exit(1);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/*
|
|
127
|
-
* load into the arguments the size and the pointer to the data
|
|
128
|
-
*/
|
|
129
|
-
args->size = count;
|
|
130
|
-
args->data = data;
|
|
131
|
-
|
|
132
|
-
/*
|
|
133
|
-
* fork off a thread to get the sum from the data
|
|
134
|
-
*/
|
|
135
|
-
printf("main thread forking sum thread\n");
|
|
136
|
-
fflush(stdout);
|
|
137
|
-
err = pthread_create(&thread_id, NULL, SumThread, (void *)args);
|
|
138
|
-
if(err != 0) {
|
|
139
|
-
fprintf(stderr,"pthread create failed\n");
|
|
140
|
-
exit(1);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
printf("main thread running after sum thread created, about to call join\n");
|
|
144
|
-
fflush(stdout);
|
|
145
|
-
|
|
146
|
-
/*
|
|
147
|
-
* wait until the sum thread is finished and get the result back
|
|
148
|
-
*/
|
|
149
|
-
err = pthread_join(thread_id,(void **)&result);
|
|
150
|
-
if(err != 0) {
|
|
151
|
-
fprintf(stderr,"pthread_join failed\n");
|
|
152
|
-
exit(1);
|
|
153
|
-
}
|
|
154
|
-
printf("main thread joined with sum thread\n");
|
|
155
|
-
fflush(stdout);
|
|
156
|
-
|
|
157
|
-
printf("the average over %d random numbers on (0,1) is %f\n",
|
|
158
|
-
count, result->sum / (double)count);
|
|
159
|
-
|
|
160
|
-
/*
|
|
161
|
-
* free the result structure
|
|
162
|
-
*/
|
|
163
|
-
free(result);
|
|
164
|
-
|
|
165
|
-
/*
|
|
166
|
-
* free the data array -- it wasn't freed in the sum thread
|
|
167
|
-
*/
|
|
168
|
-
free(data);
|
|
169
|
-
|
|
170
|
-
return(0);
|
|
171
|
-
}
|
|
172
|
-
|