From ef929aa3b508f311e0b9ad3bd043f935b77df80a Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:05:19 -0500 Subject: [PATCH 01/24] initial commit --- ex1/ex1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex1/ex1.c b/ex1/ex1.c index c4b111641..af67a54fa 100644 --- a/ex1/ex1.c +++ b/ex1/ex1.c @@ -9,6 +9,6 @@ int main(void) { // Your code here - + // initial commit return 0; } From f5fbc886c8247a2533acca94ba854794a54418f0 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:16:09 -0500 Subject: [PATCH 02/24] ex1 code and questions complete --- ex1/ex1.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ex1/ex1.c b/ex1/ex1.c index af67a54fa..ed548f630 100644 --- a/ex1/ex1.c +++ b/ex1/ex1.c @@ -9,6 +9,19 @@ int main(void) { // Your code here - // initial commit + int x = 100; + int pid = fork(); + + if(pid == 0) { + printf("Hello, I'm a child process!\n"); + } + else { + printf("Hello, I'm a parent process!\n"); + } + printf("%d %d", 100, x); + return 0; } + +/* After initialization, the variable in the child process would be the same as its value in the parent process. When the parent and child change the value of x, we can access both values of x within their respective forks. +If we were to do something like (x * 2) in the parent fork and (x / 2) in the child fork, we could work with both 200 and 50. */ From 725e928759a8faf29762b267dfd0e6d8278a166b Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:21:58 -0500 Subject: [PATCH 03/24] initial code idea for ex2 added, figuring out a good way to test this to help with answering questions --- ex2/ex2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ex2/ex2.c b/ex2/ex2.c index 4245375b9..3685daa47 100644 --- a/ex2/ex2.c +++ b/ex2/ex2.c @@ -9,6 +9,10 @@ int main(void) { // Your code here + FILE * file_pointer; + + file_pointer = fopen("text.txt", "r"); + int pid = fork(); return 0; } From 5bdb851230a9b2c3480d97d4784d44c1104fafe3 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:38:21 -0500 Subject: [PATCH 04/24] added parent/child cases for ex2 --- ex2/ex2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ex2/ex2.c b/ex2/ex2.c index 3685daa47..46c3f19c4 100644 --- a/ex2/ex2.c +++ b/ex2/ex2.c @@ -13,6 +13,15 @@ int main(void) file_pointer = fopen("text.txt", "r"); int pid = fork(); + + if(pid == 0) { + fprintf(fp, "%s %s", "Child", "text."); + fclose(fp); + } + else { + fprintf(fp, "%s %s", "Parent", "test."); + fclose(fp); + } return 0; } From 738754e454251b7d0d7e5aa96a267d674e9b476b Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:38:58 -0500 Subject: [PATCH 05/24] forgot to add write capability (r -> r+) --- ex2/ex2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ex2/ex2.c b/ex2/ex2.c index 46c3f19c4..4a91276a6 100644 --- a/ex2/ex2.c +++ b/ex2/ex2.c @@ -11,7 +11,7 @@ int main(void) // Your code here FILE * file_pointer; - file_pointer = fopen("text.txt", "r"); + file_pointer = fopen("text.txt", "r+"); int pid = fork(); if(pid == 0) { @@ -22,6 +22,6 @@ int main(void) fprintf(fp, "%s %s", "Parent", "test."); fclose(fp); } - + return 0; } From c7f0af56db3f6b13603ef5c24c16d3dfcca72086 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 15:46:26 -0500 Subject: [PATCH 06/24] fixed variable name error (fp - file_pointer, forgot to change after referencing example code) --- ex2/ex2 | Bin 0 -> 8760 bytes ex2/ex2.c | 10 +++++----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 ex2/ex2 diff --git a/ex2/ex2 b/ex2/ex2 new file mode 100644 index 0000000000000000000000000000000000000000..a5eb56ae5105c1f9507155a454af549aceb48908 GIT binary patch literal 8760 zc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0)+XkAg0-#{-?DP z+cT&Ci@9v8UPNA;tz|`-X%qA2uGRkQvi=it;690&w3fI%w3iXl`Ycv{rM&3s;DsTy K&9=& Date: Wed, 20 Feb 2019 15:53:40 -0500 Subject: [PATCH 07/24] completed ex2 with questions and text example appearing properly in the file --- ex2/ex2 | Bin 8760 -> 8760 bytes ex2/ex2.c | 6 ++++-- ex2/text.txt | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ex2/ex2 b/ex2/ex2 index a5eb56ae5105c1f9507155a454af549aceb48908..111925dd5849d0f5d20fd0756d62959e30df0b0c 100644 GIT binary patch delta 99 zcmdntvcqLV3zNv#!nSvfQN3I9RSFwdAB(#?|n`bahWM&g*cVO5jJ6WGinOhmi z+@%TO$Fl8^;$m>l$jnJ$P%TzaEoLZ5ttioB2uLhS%`4fg&z>pHXs~&v+XwOB#5n4u)KxI~X3Ah9SluY_TH*3 diff --git a/ex2/ex2.c b/ex2/ex2.c index 06e725331..acf77a641 100644 --- a/ex2/ex2.c +++ b/ex2/ex2.c @@ -9,13 +9,13 @@ int main(void) { // Your code here - FILE *file_pointer; + FILE * file_pointer; file_pointer = fopen("text.txt", "r+"); int pid = fork(); if(pid == 0) { - fprintf(file_pointer, "%s %s", "Child", "text."); + fprintf(file_pointer, "%s %s", "Child", "text.\n"); fclose(file_pointer); } else { @@ -25,3 +25,5 @@ int main(void) return 0; } + +/* Yes, both child and parent can access the file returned by fopen(). In the case of concurrent attempts, they are saved together as in the example above. */ \ No newline at end of file diff --git a/ex2/text.txt b/ex2/text.txt index e69de29bb..417ad503a 100644 --- a/ex2/text.txt +++ b/ex2/text.txt @@ -0,0 +1 @@ +Parent text.Child text. From bd40bbfd9681b5cf984524048e7972f944e9ed7d Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 16:36:34 -0500 Subject: [PATCH 08/24] ex3 complete, child/parent printing is working properly --- ex3/ex3 | Bin 0 -> 8704 bytes ex3/ex3.c | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 ex3/ex3 diff --git a/ex3/ex3 b/ex3/ex3 new file mode 100644 index 0000000000000000000000000000000000000000..3bd9a6ccc4df30ce7a1d7017bda46c909b5d1f8d GIT binary patch literal 8704 zcmeHMeQaA-6+gD~)i1|w*DY-awYFBIgSsZsw1-7?Q#K=8y*FcW~x*HnRftngAgSagk_+@ zCb%DJ5UIvX6*a`o67zZKnt7en^B}LnE9f?Xpj#CM=J%U0wqO!RNSxX$lPZfQ|3$4S zG6(Prfb1w%pI3;;`$T~`$Dzu2*p5W9Ym|14(vJCM85nc!AN7r{sPq?gt0?WBp+_|MEItGi`;cN>>mvVY8_2-{N0{??Xl zsd!T=na+;9kKF~|hPc0i{<^#9Q@<+t2ON(9>V7MX=8YT- zX0lJfld+^Rnv8?4Q>~seVp&5Ui6zsB42@*c649YE(iLvgw=3I~9q8YUKfb$g6lfgy zdF3}Gmr>oLh!M@#_X$qVp2m}@!Ph5>v>eEu$#22s)D%^X7M$l4RRk=!b=_%Gf2-4; zt^Vl>KWIm1jOw`oRMw{6sJkHCm2Sly-$9k)mRImzze&Xs$-`8C{p}*smT!_wAzr^M zS%Z*~=~9MTGZ(x(1$>p-+?c4o9j1#R{`2sZm# zwF-0JK*J9P>o>InOz+1I^=M5RGHq(!s}bf6V(Y3Jv5X|9Xfl?7v6$=eF{R=){)FPQC5e)h_8KR|wU4;s#; zF|gi?)n^fMy)Rli=f@X}Hnj`#)i=I|b|q);kwNit@AboILuGsdzPaBo6pMw9JI{99 z`8kDqmTraFxz`Y$`pO;1uRM1I$6@Xm$~Tsudxpw~u`Im4i48*N^P$H=g<_~D6pb9; zvQX>C&K++eez2=>yQ}b4WGl5)r=9=MGgphI+R>Yazxj7O9+ASkk;3hE^iaI#nl^R8 zrR}_tf0ri07kWcq4E2T%h4c$2%H#Jw&JW>FP8Ao<<>5psm4Ts5Cf+}hzz(=JdL9WN zr}_4)4~xYwBmWdO9YOv8_Wl**DdcY;zlMAz&K`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nwbH)&sM7;kFl2atkQ%%Wii_63dcve*TQK=XlwLQ~tKYp8uz3r2UU6I16#R484p6Yy6xa7;->3 zk7a%7mPPo!wCCqHS)+=&Nonu=?{(V$$YIa<27mu-5#Gu-r~NsHJ?ABtWcweKO-0E$ zes3a*yCJcLNP+j6{5{mE@08y{n|g~q=Q$1J6v?UYl>dl2H2!kBmhuVzN3{Pd+EQ29 zp7SRDUd`X7<#3eZ;dyY%(LR4qoTpA9IpbxS`9Dy{8h Date: Wed, 20 Feb 2019 17:06:13 -0500 Subject: [PATCH 09/24] ex4 complete, today's MVP met. Going to keep looking at the ex3 syntax changes to learn more about process ordering and the different versions of exec() from ex4. --- ex3/ex3 | Bin 8704 -> 8752 bytes ex3/ex3.c | 7 ++++--- ex4/ex4 | Bin 0 -> 8600 bytes ex4/ex4.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ex4/ex4 diff --git a/ex3/ex3 b/ex3/ex3 index 3bd9a6ccc4df30ce7a1d7017bda46c909b5d1f8d..6b768dbefb42851c34d32896f72b44f0d13e412a 100644 GIT binary patch delta 1546 zcmZ8hTWlLu5WROder(#Qkfz`x?f~rPy>t&0If*_3l$U4|8$*Hff|vK&$t$BL zPKMrmJ@hDfJ2^T5NBBcl!r?~<2N~W^d*B*BHFdy|&`2$)4SEf$Gk;js3#Q3k0ivGI zPnfD>=vHS|tt(oX)VkilP_1nOwcW4ah~bx5aI;iHX?vMr%5Xu$Cm3e*n|TdC&+rt_ z99hkAggNRM{#e5t;*m6BO*(GIQpFe4)Gz8xWh*`qThHh5nAG*Smae{r%tLFYS(r5`Q!|ry$QgO*2V7b8{eNmT zoi?>z{Sv|NzNHNoIE~{APu}^49nm6N0mdhHlD{`dqQ|1oMpL!uV057GV%t}i0Iulb zK4y=`QnzENAN%&+(5`CvE?@oYZmp)Czc~S2<}vXL1n*$g7A)C^)(Kb45&9i$n!~1t zFqVK;%LA?vj1DmJsLe6U^)#5d{@hW^t7f5KG;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`3BpCj*wYM z+9xT4>vkVK4psXIO@Z$4>APxFc*xgDN)U4xv;Z>>AI(F~anU;`Gc8K_o|K=#b=?Jf zv;`8*9n2iiJs1(t-Kv!oAc?3Xkd5rZIYbfkcdKnAh0;S;1hQj2u61C4dWTzek~B&W zT^6W=Y;y@GJMtJ^Mf(B5fVw6_4`mN>IMRa$h1khKxr3&D7-n1^D7dWH-!+#(m*B2z zQdzaY3!U#`kxHjQr{Qnp5eT^rFMl8ZryxG{4#Jz8adV%Kkw>BG_IT5H?VMT!C*&L9 zX~)lwc6pMCr}A8o*5;4lSs7JEy_4WjPx*f*{rUI6=@^{u8sQ^!4SF|(t(7z{SU4aX zEK<)ArI_?i(&Co~1}M&2?J;zwMui9CUnSCU(0dI%FSU88ZG&X5p%tXI0NLKKR+6X$ zmEQ2b?_^g-;Opr#v}O|#i1&r{l)ROc+)4s+=(8fVD^Nk7<_b#E=PS_r4Q*Dga~9(L z;r8Zo(`IZK|8p)V^!v5{evXy?ux(pLY@3TV-y+4!$@#G#xyT4q{9&!RRt8#tuP=`L b5M%=*TG}a=LEeIDAgn#=YM{fQ5BUB8ErxA{ diff --git a/ex3/ex3.c b/ex3/ex3.c index 2ceacd87c..d469a2370 100644 --- a/ex3/ex3.c +++ b/ex3/ex3.c @@ -10,15 +10,16 @@ int main(void) { // Your code here - int pid = fork(); - waitpid(pid, NULL, 0); /* if I'm understanding this right, the wait(NULL) here ensures the child is printed first */ + pid_t pid = fork(); if(pid == 0) { printf("%s", "hello\n"); + wait(NULL); } else { printf("%s", "goodbye\n"); + waitpid(pid, NULL, 1); } - + return 0; } diff --git a/ex4/ex4 b/ex4/ex4 new file mode 100644 index 0000000000000000000000000000000000000000..513f4ff3e0ad4f6f9bc196064c114eb63dee353a GIT binary patch literal 8600 zcmeHNeQaA-6+gD~)i1}*+AeJ;`UEXxgS1p3=Gc|} zT+(WSj%<~z(NPJ6@(&UcOal#xAq^CSw6hUsE2}vg>a*17wY+}0r$~wHd{SMIWH&jO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0qI{xy0 zi7RLmB1_?kT=MW`-P*={iBsGNPxQN(AxzpY>%eX%dhNM8gbo1&2n&}HCnJ3Ik+rH! z_#)S1nbcin2EXPP6nz7$P99a&Epxxx?l{M9^1yuz3wPor?P2%${}Hw8pWozoYw Date: Wed, 20 Feb 2019 17:21:09 -0500 Subject: [PATCH 10/24] reviewing some ex3 changes to learn more about the effects of waitpid() --- ex3/ex3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ex3/ex3.c b/ex3/ex3.c index d469a2370..fc2b22ff9 100644 --- a/ex3/ex3.c +++ b/ex3/ex3.c @@ -11,15 +11,19 @@ int main(void) { // Your code here pid_t pid = fork(); + waitpid(pid, NULL, 0); if(pid == 0) { printf("%s", "hello\n"); - wait(NULL); + // waitpid(pid, NULL, 0); } else { printf("%s", "goodbye\n"); - waitpid(pid, NULL, 1); + // waitpid(pid, NULL, 0); + } return 0; } + +/* currently testing out the results of implementing waitpid() in various spots in the code */ \ No newline at end of file From 8d26bd0ae9e66f364778b902e5bae812f93b9d8e Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 17:36:01 -0500 Subject: [PATCH 11/24] found the issue: I had the waitpid() after the printf() statement initially, child process now always prints first and waitpid() is in the proper location --- ex3/ex3 | Bin 8752 -> 8704 bytes ex3/ex3.c | 7 +++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ex3/ex3 b/ex3/ex3 index 6b768dbefb42851c34d32896f72b44f0d13e412a..8b12e293d7d9bf5a0038079367e471dbcdde24e5 100644 GIT binary patch delta 1471 zcmZ8hUuc_E6u9@AY1TG>Dxp+dzwJSi39iZP+|4K~VeQ00Z9pmdFlnI{ z8A3CCw=O{A+pEuvO2pzd?$^0~^g_SyrfKD&!OXfOSGS@?v;5z-e z!?`^A@~bCK-}`8H(z|>5huw#vt2g1Q5{3h67wv_L;-&^r)eTJTf-R*Bl4=V~sZo zZ*ud4of=Z`8po95ErGKf^HClY1-`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`0=ChXX5EE%s2OHL? z;!R#Yf9*~d9+4jPNdG@ge=1$#~@9? z6-SWv!kVL#o&nhzl($69@L{bN74LaPHs0JmsLX*h7;P5;p@8uWY4$%nbJPJ&B>}u|R7927{Ndrm3tS5@W*F1xQ z-45;bAJ8%^*0X!xMy^5F8^r{Nyb4{05nOAK^+r`4$Lqgz8K*%eE>eJ!S5etiGdgK- zLe@~aFxj&p`|jWKVQyW;z08_~xKEMTQ()8wL%vSTJnL(PqR+1`qL-Us<#??PCuEP! zm3&VKGW$(v+LJwr16_mdk@m>GxqzCYa}y0AN-x7~V^mJ@_NLgYMe2nTYI9th<5~xV zo1#*lYx8idDJB&;Dnhm?c5h6!_>MDB!X4Yk8U?jECTI8|Gc{(e6bv;-rA@Bgge>~p zYq!Pp`4&p(v&>7k3~C@&SKz2%MIZb_dSEmVlJ5Uvvw>Kx-=-M>{I4TYkT u#v6p~3dJP${uw3VdWaQO4R_KLa4g&@z2`CvBm=YInB-SX^fZ*h!G8gYy^fUt diff --git a/ex3/ex3.c b/ex3/ex3.c index fc2b22ff9..afc7ba6bc 100644 --- a/ex3/ex3.c +++ b/ex3/ex3.c @@ -11,16 +11,15 @@ int main(void) { // Your code here pid_t pid = fork(); - waitpid(pid, NULL, 0); + // waitpid(pid, NULL, 0); if(pid == 0) { printf("%s", "hello\n"); // waitpid(pid, NULL, 0); } else { - printf("%s", "goodbye\n"); - // waitpid(pid, NULL, 0); - + waitpid(pid, NULL, 0); + printf("%s", "goodbye\n"); } return 0; From e8b91adfdbf4069e23d90b21b30ed27cc220fc7d Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Wed, 20 Feb 2019 17:46:06 -0500 Subject: [PATCH 12/24] added error handling to ex1 --- ex1/ex1 | Bin 0 -> 8848 bytes ex1/ex1.c | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 ex1/ex1 diff --git a/ex1/ex1 b/ex1/ex1 new file mode 100644 index 0000000000000000000000000000000000000000..e908daecb190731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;U14j%3tJ0g z!dAR4%~t-^(|^DBz`z&X8+v*_oot(V?}IzvNW|nH_Si$1QoK?vK9D_9CD)rVpm;D& zsK$IB9PesB96Z$>Y=DmLe`FZvDS%8s#~=Y*HvJJx&$Q|31-G>fZ*C+2>3^i(Vfmqxa<_6{}DO-p^}mf%cKzuc6+>7@RzJfub|N$Ke+o?W(=ji7!4 zvMtp9?HSHq&)9YUWA9nUev;ZeM)=!_=)UMH(XYHi1$t-4y)cw`tUveRVaWG5;7RkCqf>TR;)c+U2; zbQZ7KLgpX;HjD)RWLqC7C)OqEg{Z^XFTb?fB41c#rP`+>f!F9uVZgq_e3e-8NRRzP z(@4s`K~ks1ow;GgwT>rTNmGQV0IRtMSh8TVqb-n7A{?*?I3pK)Rrt*~<7lLev{HW{ zFSz1r!JP0Z6)s-fO{{T&(vrFvEEPH-C;VaDq?KXHe(+tVH*iH{^`)?r!u}xaFE~`{ z!Gtp-WpKvnRxFU9;U0+vaVs|3FlOyA$E^x^Zc8AEhX`KjsuHkhH_Jluv>AUbYm@ieaOawLWO~JB*97I91yy&jB0{%mx$K~=c0vV>-0cp@ zbii-AgOuFo?j13G1$B(5+Oid!M4aykcTuwJ1z>W7Yk(QDPD*M&M$0`F#pigV=)KD) zW-0fSd+hAlU~&nE%D1{TnG#wtdktzHzgDbBPA2sN&X;>elAdxIKdaa>lCOwMxZSrP zt;4!?A+1=L8S%_t#V$eo Date: Wed, 20 Feb 2019 17:52:38 -0500 Subject: [PATCH 14/24] added error handling to ex3 --- ex3/ex3 | Bin 8704 -> 8848 bytes ex3/ex3.c | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ex3/ex3 b/ex3/ex3 index 8b12e293d7d9bf5a0038079367e471dbcdde24e5..092bb2a9be5b2a317132cfa86204e82b8fdeec49 100644 GIT binary patch delta 2173 zcmZuyYiyHM7(QRWeZ9fDe%*T6wXHZ9D(wK-xWw!$4EU-u8JA(b3|d?(lf^Y#2lB(L zW;oISrsIvtq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3(^Pg5WtLz-g<2aSoBkkG;<6S{8>+CE3mQ^OpQyyT4^3G@BbfNmHEKxH2SO|XV+|z6)Q7U3JA22F#*^GR^L^)> zd(WIXXD0Lfcw44I%xj{AO6iJvs_tvkO})aAoBFA{A!CFup(u#l1>3Z)gr;?+kZB!U z{87B4c#zt+*NZ5% zmno))ZQoIFmSUR9c3#03DHbT6S8yxhfpZxo6bV0wrwjdZdPAQ0ZKt~@zLFotipeWW zL{Td@v{AD48Akp!VDYyRlIyZ2NUz)=qmm~cn&tHUF;9+eMV~|LTcn2KIy#?M_U~J! zX%B={e2dz9HS&jl%3#vf9xSI{6MJ#%t+(;yzVEfS;E1lxI9j%N z9<$oI3|3HoP{aNg~~CO#w639 zGJOS7q8-*b4IH)RxEzS0o0B0XIt4w+qIPpL3Nn(sqD^E?(FaHbzC>#Re{c7=<;uFVZQHW&Ep9q}EOyz1=18=ja+ zBP+eihZsNn7*AgyN2-Vn*X%`)$s|BUz(pB5~l;+8Ny@3P6@6$tuX8~ zB6n8d=A2SIigU1Eu4386eb1+1#_y1~VQO?9snGVMQov=!6uKeka#yO~$9ly^$O=YL zs|+u>+(tUYRN5isI^-1jN}rdkfdlFPl&?dEuRw=%M@T=^mgX3qv! z4Z9vmR68!mKD-$SS4*PWmook4pmabA*{l#%P?oV}aJ^bGshu|?!0**fVxBqWnNtOX zy^^Rl?;2yVVZ4%2O*H~@-exhu-e-bUts8c|l4+i?^BSo4;r0yXnbS9r@--S+S#hea z`I^fZ8rNaA_!F>a{Q;BOS@>e>{Y|D-=Ci6>c+)@0(as8BKCGY-s0%iWYI$Y$2QWa` l~o`F=2|6lugk$(UH diff --git a/ex3/ex3.c b/ex3/ex3.c index afc7ba6bc..14b02bae9 100644 --- a/ex3/ex3.c +++ b/ex3/ex3.c @@ -13,7 +13,11 @@ int main(void) pid_t pid = fork(); // waitpid(pid, NULL, 0); - if(pid == 0) { + if(pid < 0) { + fprintf(stderr, "Fork failed!\n"); + exit(1); + } + else if(pid == 0) { printf("%s", "hello\n"); // waitpid(pid, NULL, 0); } From d9c5c67d65624e09ff5a6ab07a8733ef60542e42 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 15:43:03 -0500 Subject: [PATCH 15/24] set up basic code for ex5 --- ex5/ex5.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ex5/ex5.c b/ex5/ex5.c index cbf3b8e61..85aac22e5 100644 --- a/ex5/ex5.c +++ b/ex5/ex5.c @@ -17,6 +17,13 @@ char* msg3 = "hello world #3"; int main(void) { // Your code here - + char inbuf[MSGSIZE]; + int p[2]; + + if(pipe(p) < 0) { + fprintf(stderr, "Pipe failure!\n"); + exit(1); // yesterday's error handling example + } + pid_t pid = fork(); return 0; } From ef362409dc71375910ef09bf67f19255d3b1022f Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 15:57:04 -0500 Subject: [PATCH 16/24] ex5 complete and outputting successfully --- ex5/ex5 | Bin 0 -> 9104 bytes ex5/ex5.c | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ex5/ex5 diff --git a/ex5/ex5 b/ex5/ex5 new file mode 100644 index 0000000000000000000000000000000000000000..ae913b025a34992bd884dbcbcf0586a3eb962fa6 GIT binary patch literal 9104 zcmeHNeQaA-6~DHVH2rd%F6**%qK|%zY$%?SCLv{v*-4zfR7sn*Nyi51ixb<4SH}+a zbDIt}0@=D*pW%x{t+VQpfy z@Qcmj7Eu96Ib42OgWM=FUnbYgD@o4^`>DNBdAUOUV@{&DBOV)W zZN4KOZivScnaPI9w$_H$W^X#_ZIb;)|ERlb&wy-+^QeG?G1tI_a{%ktUHM1%j?9Uq-_+n~3kcI>S=~q(Zt8pbdqvxT^%dxde{=DCWmk z0`Dk+V-^&+?1X(O=KnJ#@VXLs3*gnFPRx3SpdYxcPZh zO?ZB6z)znEr$=5k{W%j(OPa*h>AzK~Gv#-!QH1))oL;{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235d9fe 100644 --- a/ex5/ex5.c +++ b/ex5/ex5.c @@ -22,8 +22,28 @@ int main(void) if(pipe(p) < 0) { fprintf(stderr, "Pipe failure!\n"); - exit(1); // yesterday's error handling example + exit(1); /* yesterday's error handling example applied to the pipe */ } + pid_t pid = fork(); + + if(pid < 0) { + fprintf(stderr, "Fork failure!\n"); + exit(1); /* fork error handling */ + } + else if(pid == 0) { + /* write the msg entries to the pipe */ + write(p[1], msg1, MSGSIZE); + write(p[1], msg2, MSGSIZE); + write(p[1], msg3, MSGSIZE); + } + else { + for(int i = 0; i < 3; i++) { + /* reads the data from the pipe and outputs it */ + read(p[0], inbuf, MSGSIZE); + printf("%s\n", inbuf); + } + } + return 0; } From 86c5673f9da2917c1c12ff82b04101dcac7abdf4 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 16:10:37 -0500 Subject: [PATCH 17/24] set up basic ex6 code, just need to add writing logic now --- ex6/ex6.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ex6/ex6.c b/ex6/ex6.c index 17532d65f..f8706267e 100644 --- a/ex6/ex6.c +++ b/ex6/ex6.c @@ -12,6 +12,7 @@ and `clock_gettime()` should work just fine. */ #include +#include #include #include @@ -21,6 +22,17 @@ and `clock_gettime()` should work just fine. int main() { // Your code here + uint64_t diff; + struct timespec start, end; + int i; + + /* basic structure */ + clock_gettime(CLOCK_MONOTONIC, &start); + sleep(3); /* this line will be replaced by the writing, just using sleep as a placeholder */ + clock_gettime(CLOCK_MONOTONIC, &end); + + diff = BILLION * (end.tv_sec - start.tv_sec) + end.tv_nsec - start.tv_nsec; + printf("Time elapsed: %llu nanoseconds\n", (long long unsigned int) diff); return 0; } From 83a17937a5af8bee723daa350dd51780214b7a80 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 16:20:43 -0500 Subject: [PATCH 18/24] ex6 now complete, today's MVP met. Will begin work on stretch shortly --- ex6/ex6 | Bin 0 -> 8872 bytes ex6/ex6.c | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 ex6/ex6 diff --git a/ex6/ex6 b/ex6/ex6 new file mode 100644 index 0000000000000000000000000000000000000000..7930946561c0fa3fe6aaa31672d6f217f1b7e0ff GIT binary patch literal 8872 zcmeHMeQaCR6+gD~)i1{>1wzZ#CupU#D6dILLuj?t&PV&wrKPk96tVQhiJio&V@LLL zNjr^|1qxm%WFKM?(j>G`HuguSX^ia;n$pr1{tB8vNSh$rU`ps180N4loxx63MQP?dsT0_%sJ5T-GjwA~{G5+SRkb zNtbBvyHNKG z_3>CDGgd#=(p=x%q^FbmW>s(UPr5tz^r(`g9W|6F=2iHoF+lkT4|VBPA8h)|*ygH# zUibKuzly*8n?cg2CLkaAdU*m0LkKo}?r|9!Brc#vL{=_90q$M|U$zKNg_QEMeG&X# z#5Mf8X(Ixq{M?Fo4XlO(fj(s-;|H*P2dFul!8FrWc;JvZFnq`y49DUynu;Z?K}cJX zWX6KQSUj3Y!azKUIzv&*ij73khV02OWtk)4SOOkM#Vo>yMv@7}P1xDh+1h4q)|>LF z#yj%K&H5G!$p>ESF)#jrpM-i4r@oPKv?>-`K|MRj*!RBm6n2{rMp@3Rj^WJo!dFoy zny>CtoccE3znGSGpgEpz3ryE?`&43@$`#TaI8QZ|Rp-EIoC!5JaG5)l*W$pP>r2pq zQ`ths_}{9G6Xm~Ns)6yylvO@EjycBoxvI0GVe{OUAD~KZ{g3cjy*7v`l7}gCZYGDc z{%Mk_N^{dn{x-=}mANS;f0JaY!rUn(e}iNSeeM}0A0?SWo|{neEhrC8psc9z{m$%b z2aW8Xjq!Ib@9plqFcrX+#JF(gnMz_8-lzz|>`&3~lfmk>?Eo*BSm7R{p8CNUpZ6Qt zcMq?5fm~5FYkE&pMs5a`A6EW*&r+=hb&+4B{2t?>zbgl4uK3V_k-co3ncZ%9&Ks{? zv98a1TPEJB*Fx`EyZmEccx8zOkg4fG!`TD|)_cDEd4xP4tCCJ@xB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O6FiJ5i`T7RQQM)O<1WTFqjIDM9oNMWaJ2%I3yD_ts>RvShEUm$G*_+ z4zpuVJH}@RE9oMW2$=2n?FsGfY(p(aj=Eh$2=8#s4#Tv)8SVSP+}U+kYpBb-YsZfL z9o=SksI{wuN>F!_1L=$k9?Z_}-DaU#x_7rxqjZP+<59lb3_GSOj#EhQsM$&?83@=+EX> z%Fa0)O{HVWM3G=(UJCDs$beI$aSL=+Jsp$!P!dHeI)+agzo?W{-K0l{dBhG!(1}R4 zsXcUU3rT-v0M)RV@JMU`V@O)$9uewu9orFfoJ1oyF`RS!ze&^k8keB_IYIWJ^8HHA zFH#2SI_XvvD)EoYh9cRo%J(6SabdE4icH@#oc6M>wbm}Z(;i&mt29|89&27`zcZtd)dd2 zvAvx8q_;=dN z`Js>PN1e);4zMizyDobXeq`=A j?I$??Dekz>W9BCOOZ{d2r} Date: Thu, 21 Feb 2019 16:43:44 -0500 Subject: [PATCH 19/24] starting work on stretch, creating random number generator --- stretch/src/bankers.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stretch/src/bankers.c b/stretch/src/bankers.c index b44aed25c..13d4a6e43 100644 --- a/stretch/src/bankers.c +++ b/stretch/src/bankers.c @@ -90,6 +90,14 @@ int get_random_amount(void) // !!!! IMPLEMENT ME: // Return a random number between 0 and 999 inclusive using rand() + int i, count, lower, upper; /* upper and lower will provide our rand() range */ + lower = 0; + upper = 999; + + for(i = 0; i < count; i++){ + int rng = (rand() % (upper - lower + 1)) + lower; + printf("%d ", rng); + } // ^^^^^^^^^^^^^^^^^^ } From b8b1dc907d58c8ea5b4c2707ca163cda23371dd3 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 16:45:02 -0500 Subject: [PATCH 20/24] forgot to add count value --- stretch/src/bankers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stretch/src/bankers.c b/stretch/src/bankers.c index 13d4a6e43..a79b00c28 100644 --- a/stretch/src/bankers.c +++ b/stretch/src/bankers.c @@ -93,7 +93,8 @@ int get_random_amount(void) int i, count, lower, upper; /* upper and lower will provide our rand() range */ lower = 0; upper = 999; - + count = 1; + for(i = 0; i < count; i++){ int rng = (rand() % (upper - lower + 1)) + lower; printf("%d ", rng); From b3b9bf3412ce8c8fc57beffc810e7960175a0b63 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 17:40:56 -0500 Subject: [PATCH 21/24] doing some research for the next part of the stretch problem --- stretch/src/bankers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stretch/src/bankers.c b/stretch/src/bankers.c index a79b00c28..9d5191806 100644 --- a/stretch/src/bankers.c +++ b/stretch/src/bankers.c @@ -94,7 +94,7 @@ int get_random_amount(void) lower = 0; upper = 999; count = 1; - + for(i = 0; i < count; i++){ int rng = (rand() % (upper - lower + 1)) + lower; printf("%d ", rng); @@ -129,6 +129,8 @@ int main(int argc, char **argv) // Store the number of processes in this variable: // How many processes to fork at once int num_processes = IMPLEMENT ME + + /* learning about getopt() right now to try and parse arguments */ // Make sure the number of processes the user specified is more than // 0 and print an error to stderr if not, then exit with status 2: From 4da6f305a7424cb996a28132e815170eb7870c91 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 17:52:48 -0500 Subject: [PATCH 22/24] getopt() seems unnecessary for now, added initial argc parameter check --- stretch/src/bankers.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stretch/src/bankers.c b/stretch/src/bankers.c index 9d5191806..9ac030d0b 100644 --- a/stretch/src/bankers.c +++ b/stretch/src/bankers.c @@ -125,11 +125,14 @@ int main(int argc, char **argv) // message to stderr, and exit with status 1: // // "usage: bankers numprocesses\n" - + if(argc == 0) { + fprintf(stderr, "Usage: bankers numprocesses\n") + exit(1); + } // Store the number of processes in this variable: // How many processes to fork at once int num_processes = IMPLEMENT ME - + /* learning about getopt() right now to try and parse arguments */ // Make sure the number of processes the user specified is more than From eccf103e5d7eadc0bec9ff6283a342401e509230 Mon Sep 17 00:00:00 2001 From: Evan Carlstrom Date: Thu, 21 Feb 2019 17:54:01 -0500 Subject: [PATCH 23/24] bankers.c running properly so far --- stretch/src/balance.txt | 1 + stretch/src/bankers | Bin 0 -> 13768 bytes stretch/src/bankers.c | 4 ++-- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 stretch/src/balance.txt create mode 100644 stretch/src/bankers diff --git a/stretch/src/balance.txt b/stretch/src/balance.txt new file mode 100644 index 000000000..1746da631 --- /dev/null +++ b/stretch/src/balance.txt @@ -0,0 +1 @@ +10000 \ No newline at end of file diff --git a/stretch/src/bankers b/stretch/src/bankers new file mode 100644 index 0000000000000000000000000000000000000000..f922dbc912546168e75ab9b102cd64ec0d14597f GIT binary patch literal 13768 zcmeHOeQX>@6(8T(iSyC(rA?YNMa>Bsa9Vt^+r%V|Aa}MeSqCRIi4#CHU7vk>_7VHe zy4!1e{pP(lZ{Ez#?aqup8|m2Lsj3p3JmMpQxXvXZ30Zd`YJ-wh*cP!w zgv2`W9MkIj|FV;gk*;4dn_0=ScyF(O7)deNM$X0 zwa#Lh3K5V1>5;Gg+awFxEi+8Vlphm{vL3OdSFiNyl^)Y+0ivc;O3K8Ab0?FjLn181%@`|2FxR;9gZuOKiY8i z#g~nJcdUH!>B;WB@zc9WeibgVA=_nDETc*I);C6ZXn>oaVt{U(4~tzD@U0c_6%}wA z4(040sDP&`;2*1iKUe`@QvrVrcmS6>WdW4)v!Me1=?XaYXE{5|D&V~p@cIh)rV98i z6>u8=E5uqc5$Hw^^OL;ehH=?T!?0Nx!wFMlhSG_o85fy!G#L|dGo4NLMomK;j-qhL zNT*Y25l^KL30=>a(cVLPZ~q}Z9!(60KEoVJ#6;SN#>7CzFb;`~8H0j|A5JG=A!?=) zqIV#bF+^&}NWuVBO;*yTJ{V09(l?k&Dnu7MJK9@X^}B+bin+Ujo5^ht{=D)|IqT0t znPW=NgGW9S{QRy=ByON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MzIIq zlgTKX@(3E8Ok-t47Ul?XdSab|b7K0g2lTyaT(%BGY2#QPcymh0&^XPj^L9=-I*I2* ztTS{@OxMw|JmRRw`N44XHyzw_>e2B%CxWAUI-U1R4eHUs6g~~q(LJY>2xg89n$aFm zGi}j+&f(0UkscDkWXd#x;g>IsM_Jk!h?0WJ4GowgC_6BSY_Kl{)-hpKtv~rZ! zH7se%2Iq<1kBin6xPJa#d_+0?K_$%ovmDbyD5o_F=J~sFOeyfXhTDH-R?v3 zD$06HXMx-G`Fm?DU@5SlN`0O`*HJ*Wxc&T|KM}Ar-1-W(3UT+Ma;m?vh*%lc-|WIk zmJ-ty$aCGYK;8bWCeGz7sBjl6?G(qp&A@EHVun Date: Thu, 21 Feb 2019 18:07:24 -0500 Subject: [PATCH 24/24] first outline for stretch solution, working through some errors --- stretch/src/bankers.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/stretch/src/bankers.c b/stretch/src/bankers.c index 50358ce34..a8af00cc1 100644 --- a/stretch/src/bankers.c +++ b/stretch/src/bankers.c @@ -165,17 +165,29 @@ int main(int argc, char **argv) // Open the balance file (feel free to call the helper // functions, above). + + int fp = open_balance_file(BALANCE_FILE); // Read the current balance + int read = read_balance(); // Try to withdraw money - // + + int withdrawal = get_random_amount(); + // Sample messages to print: - // + if(withdrawal >= balance) { + printf("Withdrew $%d, new balance $%d\n", withdrawal, balance); + } + else { + printf("Only have $%d, can't withdraw $%d\n", balance, withdrawal); + } // "Withdrew $%d, new balance $%d\n" // "Only have $%d, can't withdraw $%d\n" // Close the balance file + + int fp_close = close_balance_file(BALANCE_FILE); //^^^^^^^^^^^^^^^^^^^^^^^^^^ // Child process exits