Advertisement
HimikoWerckmeister

Untitled

Feb 18th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.94 KB | None | 0 0
  1. pthread_exit(0);
  2.  
  3. }
  4. int main(int argc, char **argv)
  5. {
  6. if(argc<2)
  7. {
  8. printf("You passed in less than two arguments:");
  9. exit(-1);
  10. }
  11. int i=atoi(argv[1]); // N
  12.  
  13. //int limit=argv[1];
  14. pthread_t tid;
  15. pthread_attr_t attr;
  16. pthread_attr_init(&attr);
  17. pthread_create(&tid,&attr,A,&i);
  18. pthread_join(tid,NULL);
  19. for(int j=0;j<i;j++)
  20. {
  21. printf("%d ",iArr[j]);
  22.  
  23. }
  24. printf("\n");
  25. if(iArr != NULL)
  26. {
  27. free(iArr);
  28. }
  29.  
  30.  
  31. }
  32. /home/echo/cmpt300> ^C
  33. 3 man gcc
  34. 4 cd ..
  35. 5 cd ..
  36. 6 ls
  37. 7 gcc -pthread -std=c99 fibonacci.c
  38. 8 ./a.out
  39. 9 ./a.out 10
  40. 10 history
  41. 11 man 2 fork
  42. 12 cat fibonacci.c
  43. /home/echo/cmpt300> !12
  44. cat fibonacci.c
  45. #define _GNU_SOURCE
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <pthread.h>
  49. //int i=0;
  50. int *iArr=NULL;//
  51. void* A(void *arg)
  52. {
  53. //int limit=(int *)arg;
  54. int *limitptr = (int*)arg;
  55. int limit=*limitptr;
  56. iArr=malloc(sizeof(int)*limit);
  57. // Dynamic programming solution to find the sequence of fibonacci numbers
  58. iArr[0]=0;
  59. iArr[1]=1;
  60. for(int i=2;i<limit;i++)
  61. {
  62. iArr[i]=iArr[i-1]+iArr[i-2];
  63. }
  64.  
  65. pthread_exit(0);
  66.  
  67. }
  68. int main(int argc, char **argv)
  69. {
  70. if(argc<2)
  71. {
  72. printf("You passed in less than two arguments:");
  73. exit(-1);
  74. }
  75. int i=atoi(argv[1]); // N
  76.  
  77. //int limit=argv[1];
  78. pthread_t tid;
  79. pthread_attr_t attr;
  80. pthread_attr_init(&attr);
  81. pthread_create(&tid,&attr,A,&i);
  82. pthread_join(tid,NULL);
  83. for(int j=0;j<i;j++)
  84. {
  85. printf("%d ",iArr[j]);
  86.  
  87. }
  88. printf("\n");
  89. if(iArr != NULL)
  90. {
  91. free(iArr);
  92. }
  93.  
  94.  
  95. }
  96. /home/echo/cmpt300> !22
  97. Invalid command number/home/echo/cmpt300> !10
  98. history
  99. 5 cd ..
  100. 6 ls
  101. 7 gcc -pthread -std=c99 fibonacci.c
  102. 8 ./a.out
  103. 9 ./a.out 10
  104. 10 history
  105. 11 man 2 fork
  106. 12 cat fibonacci.c
  107. 13 cat fibonacci.c
  108. 14 history
  109. /home/echo/cmpt300> exit
  110. echo@echo-Satellite-A500:~/cmpt300/300test/Release (copy)$ valgrind ./'Project 2'
  111. ==3697== Memcheck, a memory error detector
  112. ==3697== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  113. ==3697== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  114. ==3697== Command: ./Project\ 2
  115. ==3697==
  116. /home/echo/cmpt300/300test/Release (copy)>
  117. ==3697== Conditional jump or move depends on uninitialised value(s)
  118. ==3697== at 0x401721: zeroArray (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  119. ==3697== by 0x400B14: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  120. ==3697==
  121. /home/echo/cmpt300/300test/Release (copy)>
  122. /home/echo/cmpt300/300test/Release (copy)>
  123. /home/echo/cmpt300/300test/Release (copy)>
  124. /home/echo/cmpt300/300test/Release (copy)>
  125. /home/echo/cmpt300/300test/Release (copy)>
  126. /home/echo/cmpt300/300test/Release (copy)> history
  127. 1 history
  128. /home/echo/cmpt300/300test/Release (copy)> !1000
  129. Invalid command number/home/echo/cmpt300/300test/Release (copy)> ls
  130. ==4052== Syscall param execve(argv) points to uninitialised byte(s)
  131. ==4052== at 0x4EF8337: execve (execve.c:33)
  132. ==4052== by 0x4EF8B88: execvpe (execvpe.c:149)
  133. ==4052== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  134. ==4052== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  135. ==4052== Address 0xffeffe8f8 is on thread 1's stack
  136. ==4052== in frame #3, created by main (???)
  137. ==4052==
  138. historyCommand.d main.o Project 2 supportFunctions.d
  139. historyCommand.o makefile sources.mk supportFunctions.o
  140. main.d objects.mk subdir.mk
  141. /home/echo/cmpt300/300test/Release (copy)> cd & ..
  142. No such file or directory/home/echo/cmpt300/300test/Release (copy)> ls
  143. historyCommand.d main.o Project 2 supportFunctions.d
  144. historyCommand.o makefile sources.mk supportFunctions.o
  145. main.d objects.mk subdir.mk
  146. /home/echo/cmpt300/300test/Release (copy)> cd .. &
  147. /home/echo/cmpt300/300test> cd ..
  148. /home/echo/cmpt300> ls
  149. 300test measureSystemCall.c~ shelltesthachi.c~
  150. 9" measureSystemCall.c: shelltesthachiold.c
  151. a measureSystemCall.c:~ shelltesthachiold.c~
  152. a.out ottuput.txt Shelltestkyuubeforerefactor
  153. balor otuput.txt Shelltestkyuubeforerefactor~
  154. "Cm ouput.txt Shelltestkyuubeforerefactor.c
  155. collatz.c output.txt shelltestkyuu.c
  156. collatz.c~ out.txt shelltestkyuu.c~
  157. Collatztest.c outz.txt shelltestnana.c
  158. Collatztest.c~ prj1 shelltestnana.c~
  159. D 100 prj2 shelltestroku.c
  160. D 1000 problemset2 shelltestroku.c~
  161. dev300prj2 problemset2.tar.gz shelltestver2.c
  162. Exptest.c Project2-Shell.pdf shelltestver2.c~
  163. Exptest.c~ pthread.c shelltestverfour.c
  164. fibonacci.c shelltest.c short_answer1.txt
  165. fibonacci.c~ shelltest.c~ short_answer.txt
  166. file Shelltestdrei.c TenshiAkuma
  167. forkcollatz Shelltestdrei.c~ ThreadExp.c
  168. hi.html shelltestfunf.c ThreadExp.c~
  169. measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
  170. measureSystemCall.c shelltesthachi.c
  171. /home/echo/cmpt300> cd balor
  172. /home/echo/cmpt300/balor> man man
  173. /home/echo/cmpt300/balor> gcc -pthread -std=c99 fibonacci.c
  174. gcc: error: fibonacci.c: No such file or directory
  175. gcc: fatal error: no input files
  176. compilation terminated.
  177. /home/echo/cmpt300/balor> cd ..
  178. /home/echo/cmpt300> ls
  179. 300test measureSystemCall.c~ shelltesthachi.c~
  180. 9" measureSystemCall.c: shelltesthachiold.c
  181. a measureSystemCall.c:~ shelltesthachiold.c~
  182. a.out ottuput.txt Shelltestkyuubeforerefactor
  183. balor otuput.txt Shelltestkyuubeforerefactor~
  184. "Cm ouput.txt Shelltestkyuubeforerefactor.c
  185. collatz.c output.txt shelltestkyuu.c
  186. collatz.c~ out.txt shelltestkyuu.c~
  187. Collatztest.c outz.txt shelltestnana.c
  188. Collatztest.c~ prj1 shelltestnana.c~
  189. D 100 prj2 shelltestroku.c
  190. D 1000 problemset2 shelltestroku.c~
  191. dev300prj2 problemset2.tar.gz shelltestver2.c
  192. Exptest.c Project2-Shell.pdf shelltestver2.c~
  193. Exptest.c~ pthread.c shelltestverfour.c
  194. fibonacci.c shelltest.c short_answer1.txt
  195. fibonacci.c~ shelltest.c~ short_answer.txt
  196. file Shelltestdrei.c TenshiAkuma
  197. forkcollatz Shelltestdrei.c~ ThreadExp.c
  198. hi.html shelltestfunf.c ThreadExp.c~
  199. measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
  200. measureSystemCall.c shelltesthachi.c
  201. /home/echo/cmpt300> gcc -pthread -std=c99 collatz.c
  202. /home/echo/cmpt300> ./a.out 10
  203. Running the program with argument value of 10 : 5 16 8 4 2 1
  204. /home/echo/cmpt300> ls
  205. 300test measureSystemCall.c~ shelltesthachi.c~
  206. 9" measureSystemCall.c: shelltesthachiold.c
  207. a measureSystemCall.c:~ shelltesthachiold.c~
  208. a.out ottuput.txt Shelltestkyuubeforerefactor
  209. balor otuput.txt Shelltestkyuubeforerefactor~
  210. "Cm ouput.txt Shelltestkyuubeforerefactor.c
  211. collatz.c output.txt shelltestkyuu.c
  212. collatz.c~ out.txt shelltestkyuu.c~
  213. Collatztest.c outz.txt shelltestnana.c
  214. Collatztest.c~ prj1 shelltestnana.c~
  215. D 100 prj2 shelltestroku.c
  216. D 1000 problemset2 shelltestroku.c~
  217. dev300prj2 problemset2.tar.gz shelltestver2.c
  218. Exptest.c Project2-Shell.pdf shelltestver2.c~
  219. Exptest.c~ pthread.c shelltestverfour.c
  220. fibonacci.c shelltest.c short_answer1.txt
  221. fibonacci.c~ shelltest.c~ short_answer.txt
  222. file Shelltestdrei.c TenshiAkuma
  223. forkcollatz Shelltestdrei.c~ ThreadExp.c
  224. hi.html shelltestfunf.c ThreadExp.c~
  225. measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
  226. measureSystemCall.c shelltesthachi.c
  227. /home/echo/cmpt300> !!
  228. ls
  229. ==4190== Syscall param execve(argv) points to uninitialised byte(s)
  230. ==4190== at 0x4EF8337: execve (execve.c:33)
  231. ==4190== by 0x4EF8B88: execvpe (execvpe.c:149)
  232. ==4190== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  233. ==4190== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  234. ==4190== by 0x4012CC: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  235. ==4190== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  236. ==4190== Address 0xffeffd358 is on thread 1's stack
  237. ==4190== in frame #3, created by execHistCommandAtIndex (???)
  238. ==4190==
  239. 300test measureSystemCall.c~ shelltesthachi.c~
  240. 9" measureSystemCall.c: shelltesthachiold.c
  241. a measureSystemCall.c:~ shelltesthachiold.c~
  242. a.out ottuput.txt Shelltestkyuubeforerefactor
  243. balor otuput.txt Shelltestkyuubeforerefactor~
  244. "Cm ouput.txt Shelltestkyuubeforerefactor.c
  245. collatz.c output.txt shelltestkyuu.c
  246. collatz.c~ out.txt shelltestkyuu.c~
  247. Collatztest.c outz.txt shelltestnana.c
  248. Collatztest.c~ prj1 shelltestnana.c~
  249. D 100 prj2 shelltestroku.c
  250. D 1000 problemset2 shelltestroku.c~
  251. dev300prj2 problemset2.tar.gz shelltestver2.c
  252. Exptest.c Project2-Shell.pdf shelltestver2.c~
  253. Exptest.c~ pthread.c shelltestverfour.c
  254. fibonacci.c shelltest.c short_answer1.txt
  255. fibonacci.c~ shelltest.c~ short_answer.txt
  256. file Shelltestdrei.c TenshiAkuma
  257. forkcollatz Shelltestdrei.c~ ThreadExp.c
  258. hi.html shelltestfunf.c ThreadExp.c~
  259. measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
  260. measureSystemCall.c shelltesthachi.c
  261. /home/echo/cmpt300> !!00
  262. Invalid history command number
  263. /home/echo/cmpt300> !oops
  264. Invalid history command number
  265. /home/echo/cmpt300> !11
  266. cd ..
  267. /home/echo> ls
  268. 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
  269. a importantvnccommand
  270. AP Lit importantvnccommand~
  271. b Lab4.pdf
  272. C 9 Makefile
  273. CMPT118-1141-echol Music
  274. cmpt125 ASSIGNMENTS ouput.txt
  275. cmpt125assignments Pictures
  276. Cmpt 125 notes Public
  277. cMPT 150 Repobackup
  278. CMPT275-1154-g-group2 scraps
  279. CMPT275June2,2015.odt scraps~
  280. CMPT275June42015.odt short_answer.txt
  281. CMPT 300 short_answer.txt~
  282. cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
  283. CMPT 371 sortexp
  284. CMPTbu sublime_text_3_build_3059_x64.tar.bz2
  285. CoveR Letter.odt Templates
  286. Desktop Untitled Document 2
  287. Documents Untitled Document 2~
  288. Downloads Videos
  289. Error logs 紹介
  290. examples.desktop 紹介~
  291. fontconfig
  292. /home/echo> history
  293. 10 gcc -pthread -std=c99 fibonacci.c
  294. 11 cd ..
  295. 12 ls
  296. 13 gcc -pthread -std=c99 collatz.c
  297. 14 ./a.out 10
  298. 15 ls
  299. 16 ls
  300. 17 cd ..
  301. 18 ls
  302. 19 history
  303. /home/echo> !2333
  304. Invalid command number/home/echo> !22
  305. Invalid command number/home/echo> ls
  306. 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
  307. a importantvnccommand
  308. AP Lit importantvnccommand~
  309. b Lab4.pdf
  310. C 9 Makefile
  311. CMPT118-1141-echol Music
  312. cmpt125 ASSIGNMENTS ouput.txt
  313. cmpt125assignments Pictures
  314. Cmpt 125 notes Public
  315. cMPT 150 Repobackup
  316. CMPT275-1154-g-group2 scraps
  317. CMPT275June2,2015.odt scraps~
  318. CMPT275June42015.odt short_answer.txt
  319. CMPT 300 short_answer.txt~
  320. cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
  321. CMPT 371 sortexp
  322. CMPTbu sublime_text_3_build_3059_x64.tar.bz2
  323. CoveR Letter.odt Templates
  324. Desktop Untitled Document 2
  325. Documents Untitled Document 2~
  326. Downloads Videos
  327. Error logs 紹介
  328. examples.desktop 紹介~
  329. fontconfig
  330. /home/echo> history
  331. 12 ls
  332. 13 gcc -pthread -std=c99 collatz.c
  333. 14 ./a.out 10
  334. 15 ls
  335. 16 ls
  336. 17 cd ..
  337. 18 ls
  338. 19 history
  339. 20 ls
  340. 21 history
  341. /home/echo> ping 162.168.0.1
  342. PING 162.168.0.1 (162.168.0.1) 56(84) bytes of data.
  343. ^C
  344. --- 162.168.0.1 ping statistics ---
  345. 5 packets transmitted, 0 received, 100% packet loss, time 3999ms
  346.  
  347.  
  348. 13 gcc -pthread -std=c99 collatz.c
  349. 14 ./a.out 10
  350. 15 ls
  351. 16 ls
  352. 17 cd ..
  353. 18 ls
  354. 19 history
  355. 20 ls
  356. 21 history
  357. 22 ping 162.168.0.1
  358. Error waiting for child to exit: Interrupted system call
  359. /home/echo> history
  360. 14 ./a.out 10
  361. 15 ls
  362. 16 ls
  363. 17 cd ..
  364. 18 ls
  365. 19 history
  366. 20 ls
  367. 21 history
  368. 22 ping 162.168.0.1
  369. 23 history
  370. /home/echo> !200
  371. Invalid command number/home/echo> history
  372. 15 ls
  373. 16 ls
  374. 17 cd ..
  375. 18 ls
  376. 19 history
  377. 20 ls
  378. 21 history
  379. 22 ping 162.168.0.1
  380. 23 history
  381. 24 history
  382. /home/echo> ^C
  383. 15 ls
  384. 16 ls
  385. 17 cd ..
  386. 18 ls
  387. 19 history
  388. 20 ls
  389. 21 history
  390. 22 ping 162.168.0.1
  391. 23 history
  392. 24 history
  393. /home/echo> ^X^C
  394. 15 ls
  395. 16 ls
  396. 17 cd ..
  397. 18 ls
  398. 19 history
  399. 20 ls
  400. 21 history
  401. 22 ping 162.168.0.1
  402. 23 history
  403. 24 history
  404. /home/echo> ^C
  405. No such file or directory
  406. ==4263==
  407. ==4263== HEAP SUMMARY:
  408. ==4263== in use at exit: 0 bytes in 0 blocks
  409. ==4263== total heap usage: 1 allocs, 1 frees, 568 bytes allocated
  410. ==4263==
  411. ==4263== All heap blocks were freed -- no leaks are possible
  412. ==4263==
  413. ==4263== For counts of detected and suppressed errors, rerun with: -v
  414. ==4263== Use --track-origins=yes to see where uninitialised values come from
  415. ==4263== ERROR SUMMARY: 10 errors from 1 contexts (suppressed: 0 from 0)
  416. /home/echo> ls
  417. 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
  418. a importantvnccommand
  419. AP Lit importantvnccommand~
  420. b Lab4.pdf
  421. C 9 Makefile
  422. CMPT118-1141-echol Music
  423. cmpt125 ASSIGNMENTS ouput.txt
  424. cmpt125assignments Pictures
  425. Cmpt 125 notes Public
  426. cMPT 150 Repobackup
  427. CMPT275-1154-g-group2 scraps
  428. CMPT275June2,2015.odt scraps~
  429. CMPT275June42015.odt short_answer.txt
  430. CMPT 300 short_answer.txt~
  431. cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
  432. CMPT 371 sortexp
  433. CMPTbu sublime_text_3_build_3059_x64.tar.bz2
  434. CoveR Letter.odt Templates
  435. Desktop Untitled Document 2
  436. Documents Untitled Document 2~
  437. Downloads Videos
  438. Error logs 紹介
  439. examples.desktop 紹介~
  440. fontconfig
  441. /home/echo> sere
  442. No such file or directory
  443. ==4266==
  444. ==4266== HEAP SUMMARY:
  445. ==4266== in use at exit: 0 bytes in 0 blocks
  446. ==4266== total heap usage: 1 allocs, 1 frees, 568 bytes allocated
  447. ==4266==
  448. ==4266== All heap blocks were freed -- no leaks are possible
  449. ==4266==
  450. ==4266== For counts of detected and suppressed errors, rerun with: -v
  451. ==4266== Use --track-origins=yes to see where uninitialised values come from
  452. ==4266== ERROR SUMMARY: 10 errors from 1 contexts (suppressed: 0 from 0)
  453. /home/echo> dd
  454.  
  455. ^C0+1 records in
  456. 0+0 records out
  457.  
  458. 0 bytes (0 B) copied19 , 5.05418 s, 0.0 kB/s
  459. history
  460. 20 ls
  461. 21 history
  462. 22 ping 162.168.0.1
  463. 23 history
  464. 24 history
  465. 25 
  466. 26 ls
  467. 27 sere
  468. 28 dd
  469. Error waiting for child to exit: Interrupted system call
  470. /home/echo> !28
  471. dd
  472. ==4269== Syscall param execve(argv) points to uninitialised byte(s)
  473. ==4269== at 0x4EF8337: execve (execve.c:33)
  474. ==4269== by 0x4EF8B88: execvpe (execvpe.c:149)
  475. ==4269== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  476. ==4269== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  477. ==4269== by 0x401356: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  478. ==4269== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  479. ==4269== Address 0xffeffd358 is on thread 1's stack
  480. ==4269== in frame #3, created by execHistCommandAtIndex (???)
  481. ==4269==
  482. ==4269== Syscall param execve(argv[i]) points to uninitialised byte(s)
  483. ==4269== at 0x4EF8337: execve (execve.c:33)
  484. ==4269== by 0x4EF8B88: execvpe (execvpe.c:149)
  485. ==4269== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  486. ==4269== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  487. ==4269== by 0x401356: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  488. ==4269== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
  489. ==4269== Address 0xffeffe363 is on thread 1's stack
  490. ==4269== in frame #3, created by execHistCommandAtIndex (???)
  491. ==4269==
  492. dd: unrecognized operand ‘’
  493. Try 'dd --help' for more information.
  494. /home/echo>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement