Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pthread_exit(0);
- }
- int main(int argc, char **argv)
- {
- if(argc<2)
- {
- printf("You passed in less than two arguments:");
- exit(-1);
- }
- int i=atoi(argv[1]); // N
- //int limit=argv[1];
- pthread_t tid;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_create(&tid,&attr,A,&i);
- pthread_join(tid,NULL);
- for(int j=0;j<i;j++)
- {
- printf("%d ",iArr[j]);
- }
- printf("\n");
- if(iArr != NULL)
- {
- free(iArr);
- }
- }
- /home/echo/cmpt300> ^C
- 3 man gcc
- 4 cd ..
- 5 cd ..
- 6 ls
- 7 gcc -pthread -std=c99 fibonacci.c
- 8 ./a.out
- 9 ./a.out 10
- 10 history
- 11 man 2 fork
- 12 cat fibonacci.c
- /home/echo/cmpt300> !12
- cat fibonacci.c
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- //int i=0;
- int *iArr=NULL;//
- void* A(void *arg)
- {
- //int limit=(int *)arg;
- int *limitptr = (int*)arg;
- int limit=*limitptr;
- iArr=malloc(sizeof(int)*limit);
- // Dynamic programming solution to find the sequence of fibonacci numbers
- iArr[0]=0;
- iArr[1]=1;
- for(int i=2;i<limit;i++)
- {
- iArr[i]=iArr[i-1]+iArr[i-2];
- }
- pthread_exit(0);
- }
- int main(int argc, char **argv)
- {
- if(argc<2)
- {
- printf("You passed in less than two arguments:");
- exit(-1);
- }
- int i=atoi(argv[1]); // N
- //int limit=argv[1];
- pthread_t tid;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_create(&tid,&attr,A,&i);
- pthread_join(tid,NULL);
- for(int j=0;j<i;j++)
- {
- printf("%d ",iArr[j]);
- }
- printf("\n");
- if(iArr != NULL)
- {
- free(iArr);
- }
- }
- /home/echo/cmpt300> !22
- Invalid command number/home/echo/cmpt300> !10
- history
- 5 cd ..
- 6 ls
- 7 gcc -pthread -std=c99 fibonacci.c
- 8 ./a.out
- 9 ./a.out 10
- 10 history
- 11 man 2 fork
- 12 cat fibonacci.c
- 13 cat fibonacci.c
- 14 history
- /home/echo/cmpt300> exit
- echo@echo-Satellite-A500:~/cmpt300/300test/Release (copy)$ valgrind ./'Project 2'
- ==3697== Memcheck, a memory error detector
- ==3697== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
- ==3697== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
- ==3697== Command: ./Project\ 2
- ==3697==
- /home/echo/cmpt300/300test/Release (copy)>
- ==3697== Conditional jump or move depends on uninitialised value(s)
- ==3697== at 0x401721: zeroArray (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==3697== by 0x400B14: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==3697==
- /home/echo/cmpt300/300test/Release (copy)>
- /home/echo/cmpt300/300test/Release (copy)>
- /home/echo/cmpt300/300test/Release (copy)>
- /home/echo/cmpt300/300test/Release (copy)>
- /home/echo/cmpt300/300test/Release (copy)>
- /home/echo/cmpt300/300test/Release (copy)> history
- 1 history
- /home/echo/cmpt300/300test/Release (copy)> !1000
- Invalid command number/home/echo/cmpt300/300test/Release (copy)> ls
- ==4052== Syscall param execve(argv) points to uninitialised byte(s)
- ==4052== at 0x4EF8337: execve (execve.c:33)
- ==4052== by 0x4EF8B88: execvpe (execvpe.c:149)
- ==4052== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4052== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4052== Address 0xffeffe8f8 is on thread 1's stack
- ==4052== in frame #3, created by main (???)
- ==4052==
- historyCommand.d main.o Project 2 supportFunctions.d
- historyCommand.o makefile sources.mk supportFunctions.o
- main.d objects.mk subdir.mk
- /home/echo/cmpt300/300test/Release (copy)> cd & ..
- No such file or directory/home/echo/cmpt300/300test/Release (copy)> ls
- historyCommand.d main.o Project 2 supportFunctions.d
- historyCommand.o makefile sources.mk supportFunctions.o
- main.d objects.mk subdir.mk
- /home/echo/cmpt300/300test/Release (copy)> cd .. &
- /home/echo/cmpt300/300test> cd ..
- /home/echo/cmpt300> ls
- 300test measureSystemCall.c~ shelltesthachi.c~
- 9" measureSystemCall.c: shelltesthachiold.c
- a measureSystemCall.c:~ shelltesthachiold.c~
- a.out ottuput.txt Shelltestkyuubeforerefactor
- balor otuput.txt Shelltestkyuubeforerefactor~
- "Cm ouput.txt Shelltestkyuubeforerefactor.c
- collatz.c output.txt shelltestkyuu.c
- collatz.c~ out.txt shelltestkyuu.c~
- Collatztest.c outz.txt shelltestnana.c
- Collatztest.c~ prj1 shelltestnana.c~
- D 100 prj2 shelltestroku.c
- D 1000 problemset2 shelltestroku.c~
- dev300prj2 problemset2.tar.gz shelltestver2.c
- Exptest.c Project2-Shell.pdf shelltestver2.c~
- Exptest.c~ pthread.c shelltestverfour.c
- fibonacci.c shelltest.c short_answer1.txt
- fibonacci.c~ shelltest.c~ short_answer.txt
- file Shelltestdrei.c TenshiAkuma
- forkcollatz Shelltestdrei.c~ ThreadExp.c
- hi.html shelltestfunf.c ThreadExp.c~
- measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
- measureSystemCall.c shelltesthachi.c
- /home/echo/cmpt300> cd balor
- /home/echo/cmpt300/balor> man man
- /home/echo/cmpt300/balor> gcc -pthread -std=c99 fibonacci.c
- gcc: error: fibonacci.c: No such file or directory
- gcc: fatal error: no input files
- compilation terminated.
- /home/echo/cmpt300/balor> cd ..
- /home/echo/cmpt300> ls
- 300test measureSystemCall.c~ shelltesthachi.c~
- 9" measureSystemCall.c: shelltesthachiold.c
- a measureSystemCall.c:~ shelltesthachiold.c~
- a.out ottuput.txt Shelltestkyuubeforerefactor
- balor otuput.txt Shelltestkyuubeforerefactor~
- "Cm ouput.txt Shelltestkyuubeforerefactor.c
- collatz.c output.txt shelltestkyuu.c
- collatz.c~ out.txt shelltestkyuu.c~
- Collatztest.c outz.txt shelltestnana.c
- Collatztest.c~ prj1 shelltestnana.c~
- D 100 prj2 shelltestroku.c
- D 1000 problemset2 shelltestroku.c~
- dev300prj2 problemset2.tar.gz shelltestver2.c
- Exptest.c Project2-Shell.pdf shelltestver2.c~
- Exptest.c~ pthread.c shelltestverfour.c
- fibonacci.c shelltest.c short_answer1.txt
- fibonacci.c~ shelltest.c~ short_answer.txt
- file Shelltestdrei.c TenshiAkuma
- forkcollatz Shelltestdrei.c~ ThreadExp.c
- hi.html shelltestfunf.c ThreadExp.c~
- measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
- measureSystemCall.c shelltesthachi.c
- /home/echo/cmpt300> gcc -pthread -std=c99 collatz.c
- /home/echo/cmpt300> ./a.out 10
- Running the program with argument value of 10 : 5 16 8 4 2 1
- /home/echo/cmpt300> ls
- 300test measureSystemCall.c~ shelltesthachi.c~
- 9" measureSystemCall.c: shelltesthachiold.c
- a measureSystemCall.c:~ shelltesthachiold.c~
- a.out ottuput.txt Shelltestkyuubeforerefactor
- balor otuput.txt Shelltestkyuubeforerefactor~
- "Cm ouput.txt Shelltestkyuubeforerefactor.c
- collatz.c output.txt shelltestkyuu.c
- collatz.c~ out.txt shelltestkyuu.c~
- Collatztest.c outz.txt shelltestnana.c
- Collatztest.c~ prj1 shelltestnana.c~
- D 100 prj2 shelltestroku.c
- D 1000 problemset2 shelltestroku.c~
- dev300prj2 problemset2.tar.gz shelltestver2.c
- Exptest.c Project2-Shell.pdf shelltestver2.c~
- Exptest.c~ pthread.c shelltestverfour.c
- fibonacci.c shelltest.c short_answer1.txt
- fibonacci.c~ shelltest.c~ short_answer.txt
- file Shelltestdrei.c TenshiAkuma
- forkcollatz Shelltestdrei.c~ ThreadExp.c
- hi.html shelltestfunf.c ThreadExp.c~
- measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
- measureSystemCall.c shelltesthachi.c
- /home/echo/cmpt300> !!
- ls
- ==4190== Syscall param execve(argv) points to uninitialised byte(s)
- ==4190== at 0x4EF8337: execve (execve.c:33)
- ==4190== by 0x4EF8B88: execvpe (execvpe.c:149)
- ==4190== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4190== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4190== by 0x4012CC: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4190== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4190== Address 0xffeffd358 is on thread 1's stack
- ==4190== in frame #3, created by execHistCommandAtIndex (???)
- ==4190==
- 300test measureSystemCall.c~ shelltesthachi.c~
- 9" measureSystemCall.c: shelltesthachiold.c
- a measureSystemCall.c:~ shelltesthachiold.c~
- a.out ottuput.txt Shelltestkyuubeforerefactor
- balor otuput.txt Shelltestkyuubeforerefactor~
- "Cm ouput.txt Shelltestkyuubeforerefactor.c
- collatz.c output.txt shelltestkyuu.c
- collatz.c~ out.txt shelltestkyuu.c~
- Collatztest.c outz.txt shelltestnana.c
- Collatztest.c~ prj1 shelltestnana.c~
- D 100 prj2 shelltestroku.c
- D 1000 problemset2 shelltestroku.c~
- dev300prj2 problemset2.tar.gz shelltestver2.c
- Exptest.c Project2-Shell.pdf shelltestver2.c~
- Exptest.c~ pthread.c shelltestverfour.c
- fibonacci.c shelltest.c short_answer1.txt
- fibonacci.c~ shelltest.c~ short_answer.txt
- file Shelltestdrei.c TenshiAkuma
- forkcollatz Shelltestdrei.c~ ThreadExp.c
- hi.html shelltestfunf.c ThreadExp.c~
- measureSystemCall shelltestfunf.c~ utorrent-server-3.0-25053.tar.gz
- measureSystemCall.c shelltesthachi.c
- /home/echo/cmpt300> !!00
- Invalid history command number
- /home/echo/cmpt300> !oops
- Invalid history command number
- /home/echo/cmpt300> !11
- cd ..
- /home/echo> ls
- 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
- a importantvnccommand
- AP Lit importantvnccommand~
- b Lab4.pdf
- C 9 Makefile
- CMPT118-1141-echol Music
- cmpt125 ASSIGNMENTS ouput.txt
- cmpt125assignments Pictures
- Cmpt 125 notes Public
- cMPT 150 Repobackup
- CMPT275-1154-g-group2 scraps
- CMPT275June2,2015.odt scraps~
- CMPT275June42015.odt short_answer.txt
- CMPT 300 short_answer.txt~
- cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
- CMPT 371 sortexp
- CMPTbu sublime_text_3_build_3059_x64.tar.bz2
- CoveR Letter.odt Templates
- Desktop Untitled Document 2
- Documents Untitled Document 2~
- Downloads Videos
- Error logs 紹介
- examples.desktop 紹介~
- fontconfig
- /home/echo> history
- 10 gcc -pthread -std=c99 fibonacci.c
- 11 cd ..
- 12 ls
- 13 gcc -pthread -std=c99 collatz.c
- 14 ./a.out 10
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- /home/echo> !2333
- Invalid command number/home/echo> !22
- Invalid command number/home/echo> ls
- 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
- a importantvnccommand
- AP Lit importantvnccommand~
- b Lab4.pdf
- C 9 Makefile
- CMPT118-1141-echol Music
- cmpt125 ASSIGNMENTS ouput.txt
- cmpt125assignments Pictures
- Cmpt 125 notes Public
- cMPT 150 Repobackup
- CMPT275-1154-g-group2 scraps
- CMPT275June2,2015.odt scraps~
- CMPT275June42015.odt short_answer.txt
- CMPT 300 short_answer.txt~
- cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
- CMPT 371 sortexp
- CMPTbu sublime_text_3_build_3059_x64.tar.bz2
- CoveR Letter.odt Templates
- Desktop Untitled Document 2
- Documents Untitled Document 2~
- Downloads Videos
- Error logs 紹介
- examples.desktop 紹介~
- fontconfig
- /home/echo> history
- 12 ls
- 13 gcc -pthread -std=c99 collatz.c
- 14 ./a.out 10
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- /home/echo> ping 162.168.0.1
- PING 162.168.0.1 (162.168.0.1) 56(84) bytes of data.
- ^C
- --- 162.168.0.1 ping statistics ---
- 5 packets transmitted, 0 received, 100% packet loss, time 3999ms
- 13 gcc -pthread -std=c99 collatz.c
- 14 ./a.out 10
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- Error waiting for child to exit: Interrupted system call
- /home/echo> history
- 14 ./a.out 10
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- 23 history
- /home/echo> !200
- Invalid command number/home/echo> history
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- 23 history
- 24 history
- /home/echo> ^C
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- 23 history
- 24 history
- /home/echo> ^X^C
- 15 ls
- 16 ls
- 17 cd ..
- 18 ls
- 19 history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- 23 history
- 24 history
- /home/echo> ^C
- No such file or directory
- ==4263==
- ==4263== HEAP SUMMARY:
- ==4263== in use at exit: 0 bytes in 0 blocks
- ==4263== total heap usage: 1 allocs, 1 frees, 568 bytes allocated
- ==4263==
- ==4263== All heap blocks were freed -- no leaks are possible
- ==4263==
- ==4263== For counts of detected and suppressed errors, rerun with: -v
- ==4263== Use --track-origins=yes to see where uninitialised values come from
- ==4263== ERROR SUMMARY: 10 errors from 1 contexts (suppressed: 0 from 0)
- /home/echo> ls
- 2.tgz Helpmebreakthelivingshitoutofthis.tar.gz
- a importantvnccommand
- AP Lit importantvnccommand~
- b Lab4.pdf
- C 9 Makefile
- CMPT118-1141-echol Music
- cmpt125 ASSIGNMENTS ouput.txt
- cmpt125assignments Pictures
- Cmpt 125 notes Public
- cMPT 150 Repobackup
- CMPT275-1154-g-group2 scraps
- CMPT275June2,2015.odt scraps~
- CMPT275June42015.odt short_answer.txt
- CMPT 300 short_answer.txt~
- cmpt300 skype-ubuntu-precise_4.3.0.37-1_i386.deb
- CMPT 371 sortexp
- CMPTbu sublime_text_3_build_3059_x64.tar.bz2
- CoveR Letter.odt Templates
- Desktop Untitled Document 2
- Documents Untitled Document 2~
- Downloads Videos
- Error logs 紹介
- examples.desktop 紹介~
- fontconfig
- /home/echo> sere
- No such file or directory
- ==4266==
- ==4266== HEAP SUMMARY:
- ==4266== in use at exit: 0 bytes in 0 blocks
- ==4266== total heap usage: 1 allocs, 1 frees, 568 bytes allocated
- ==4266==
- ==4266== All heap blocks were freed -- no leaks are possible
- ==4266==
- ==4266== For counts of detected and suppressed errors, rerun with: -v
- ==4266== Use --track-origins=yes to see where uninitialised values come from
- ==4266== ERROR SUMMARY: 10 errors from 1 contexts (suppressed: 0 from 0)
- /home/echo> dd
- ^C0+1 records in
- 0+0 records out
- 0 bytes (0 B) copied19 , 5.05418 s, 0.0 kB/s
- history
- 20 ls
- 21 history
- 22 ping 162.168.0.1
- 23 history
- 24 history
- 25
- 26 ls
- 27 sere
- 28 dd
- Error waiting for child to exit: Interrupted system call
- /home/echo> !28
- dd
- ==4269== Syscall param execve(argv) points to uninitialised byte(s)
- ==4269== at 0x4EF8337: execve (execve.c:33)
- ==4269== by 0x4EF8B88: execvpe (execvpe.c:149)
- ==4269== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x401356: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== Address 0xffeffd358 is on thread 1's stack
- ==4269== in frame #3, created by execHistCommandAtIndex (???)
- ==4269==
- ==4269== Syscall param execve(argv[i]) points to uninitialised byte(s)
- ==4269== at 0x4EF8337: execve (execve.c:33)
- ==4269== by 0x4EF8B88: execvpe (execvpe.c:149)
- ==4269== by 0x401422: executeCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x400E8A: execHistCommandAtIndex (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x401356: executeBuiltInCommand (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== by 0x400B5C: main (in /home/echo/cmpt300/300test/Release (copy)/Project 2)
- ==4269== Address 0xffeffe363 is on thread 1's stack
- ==4269== in frame #3, created by execHistCommandAtIndex (???)
- ==4269==
- dd: unrecognized operand ‘’
- Try 'dd --help' for more information.
- /home/echo>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement