1of 4FIT 2065 Operating Systems and the UNIX EnvironmentAssignment 2Due date:Week 12 –Submit the program and write up onto the Unit’s Moodle web site.This assignment is worth:10% of your total Unit...



1of 4FIT 2065 Operating Systems and the UNIX EnvironmentAssignment 2Due date:Week 12 –Submit the program and write up onto the Unit’s Moodle web site.This assignment is worth:10% of your total Unit marks. A"sensor"node"samples"the"lighting,"temperature,"and"humidity"every"minute"and"sends"across"a"network"to"a"destination."At"destination,"these"values"are"aggregated"for"every"5"minutes"and"a"histogram"with"a"10""minute"window"is"drawn.""The"window"will"have"2"sets" of" values,"the" current" and"the"previous""5" minutes"aggregated" values.""For" this"assignment"you"can"assume"that"the"sensor"values"are"generated"randomly"by"the"code"in" your" program" and" places" it" in" three" memory" locations" (can" be" the" global" variables).""However,"you" need" to" take" it" into" account" that" these" values" will" be" over" written" by" the"new" values" every" one" minute."You" can"also"assume"that"the" sensed" values" are"positive"integers"in"the"range"of"1"to"100."Optionally"(if"this"makes"the"assignment"easy)"you"can"assume"that"these"values"are"tagged"with"a"time"stamp""when"it"was"sent"by"the"sensor."The"time"stamp"can"be"a"sequence"integer"stating"from"1."""The"simplest"histogram""that"can" draw" is" the"average" values" for" lighting," temperature" and" humidity""for" the"past" 10"minutes" (three" integer"values)."Assume" that"the" programs" for""simulating" the" sensing,"the"retrieval" of" the" sensed" values" and""the"aggregation" and" drawing" of"the"histogram""will"be"done""on"the"same"machine."""There"are"several"ways"to"implement"this"application."One"way"is"to"use"a"busy"wait"for"the" new" sensor" values." " The" following" shell" scripts" shows" how" a" file" " is" used" as" the"sharable"resources"to""write"and"read"the"sensed"values.""Of"course"one"can"use"memory"locations" as" the" shared" resource" (see" " week" 8" lab" exercise)" and" mutual" exclusion" using"semaphores"so"that"writing"and"reading"can"be"done"correctly."""The"following"partial"simple"shell"script"is"an"illustration"on""how"the"sensor"values"are"placed"in"a"file"(script(name:(sensor01)"and"these"values"are"read"from"the"file"and"the"file"content"is"rest"to"null"by"the"second"script"(script(name:(sensor02).""(
2of 4Please(note"that"the"script"is"not"elegant"and"may"""lose"sensor"values,"if"reading"is"done"within"the"time"constraints"if"the"sleep"timer"is"large"(Try"with"larger"value"for"the"sleep"command)."This"is"just"to"show"how"two"programs"can"communicate"with"each"other"by"a"file."""sensor01#!/bin/sh#sensor value generation –simply generate integer values with a counter#initializevariable I with the value of 1i=1# loop forever generating next integer value and over writing on# to a specific file (temp_file) every two secondswhile :doecho $i $i $i $i >temp_filei=`expr $i + 1 `sleep 2donesensor02 #!/bin/sh# Read the sensor valueswhile : dowhile [ ! –f temp_file ]dosleep 2doneif [ -f temp_file ]thenread a b c d
May 13, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here