1. Homepage
  2. Programming
  3. CS350 Fundamentals of Computing Systems - Exercise 1: Weather Stations

CS350 Fundamentals of Computing Systems - Exercise 1: Weather Stations

Engage in a Conversation
BUCS350Fundamentals of Computing SystemsGOWeather Stations

Exercise 1: Weather Stations

Due: Fri, Feb 2 CourseNana.COM

Please make sure to regularly commit and push your work to gitlab so that we can see your progress.
Final submission will be on gradescope – this will be the only source of truth for grading. CourseNana.COM

There will be no late submission and no extensions, so make sure to submit on time. CourseNana.COM

Introduction

There are k weather stations around the world. Your task is to compute the current average temperature across these stations every averagePeriod seconds. We will provide a function that queries the temperature data at a given weather station and returns the current temperature. The function makes RPC calls across the network to the weather stations. CourseNana.COM

However, the weather station may take some time to respond or may not respond at all. Compute the average temperature for the weather stations that do respond, ensuring the entire calculation is completed within averagePeriod seconds. Your implementation should also gracefully handle shutdown requests from the quit channel. CourseNana.COM

Late responses should be ignored instead of included in the next batch. CourseNana.COM

If a batch contains zero observations, return NAN (this is the default behavior of floating point division by zero in Go). CourseNana.COM

You will be implementing two distinct solutions to this problem. CourseNana.COM

  1. Channel-based solution: Your first implementation should exclusively utilize channels. In this approach, the use of mutexes or locks is not permitted.
  2. Mutex-based solution: For your second implementation, you should modify your approach to instead rely on mutexes for managing concurrency.

API

Your code will make calls to the getWeatherData function provided as an argument to your aggregator, which takes a weather station ID and a batch ID and returns a WeatherReport struct. Here are the signatures: CourseNana.COM

type WeatherReport struct {
   Value float64
   Id    int
   Batch int
}

func getWeatherData(id int, batch int) WeatherReport {}

Your code should call GetWeatherData once for each weather station 0-k. For each batch of averagePeriod seconds of observations, increment the batch parameter. For example, if averagePeriod is 5 seconds, then the first batch will be 0, and then 5 seconds later, you will request a new batch with batch set to 1 and use those observations to compute the average temperature for batch 1. CourseNana.COM

The value parameter is the temperature reading from the weather station. CourseNana.COM

Every averagePeriod seconds, your code should send a WeatherReport to the out channel. The WeatherReport should have the average temperature and the batch number. (The id field can be set to -1 or left blank.) CourseNana.COM

Your code must terminate immediately upon receiving a signal on the quit channel. CourseNana.COM

Instructions

  1. Clone the repository and navigate to the ws directory.
  2. Put your code in the appropritate methods/files.
    1. Solution with channels goes in channelAggregator in channel_aggregator.go.
    2. Solution with mutexes goes in mutexAggregator in mutex_aggregator.go.
  3. Run the tests in ws_test.go:
    1. go test -v -race
    2. Your IDE should also be able to run the tests and show you the results in a GUI. (Note that if you're using VSCode, you will likely need to edit the default go test timeout to be more than 30s.)
    3. For Windows users, you will need WSL set up to run the tests.
  4. Upload the channel_aggregator.go and mutex_aggregator.go files to Gradescope. Do not change the file names, or the autograder may not recognize them.

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
BU代写,CS350代写,Fundamentals of Computing Systems代写,GO代写,Weather Stations代写,BU代编,CS350代编,Fundamentals of Computing Systems代编,GO代编,Weather Stations代编,BU代考,CS350代考,Fundamentals of Computing Systems代考,GO代考,Weather Stations代考,BUhelp,CS350help,Fundamentals of Computing Systemshelp,GOhelp,Weather Stationshelp,BU作业代写,CS350作业代写,Fundamentals of Computing Systems作业代写,GO作业代写,Weather Stations作业代写,BU编程代写,CS350编程代写,Fundamentals of Computing Systems编程代写,GO编程代写,Weather Stations编程代写,BUprogramming help,CS350programming help,Fundamentals of Computing Systemsprogramming help,GOprogramming help,Weather Stationsprogramming help,BUassignment help,CS350assignment help,Fundamentals of Computing Systemsassignment help,GOassignment help,Weather Stationsassignment help,BUsolution,CS350solution,Fundamentals of Computing Systemssolution,GOsolution,Weather Stationssolution,