Lab 10 CIS 370 Due: Week of 4/12/2021 Note: All labs are due before next week’s lab starts More on IPCs: Shared Memory Objective To better understand the use of shared memory to communicate between...

1 answer below »
attacheD below:


Lab 10 CIS 370 Due: Week of 4/12/2021 Note: All labs are due before next week’s lab starts More on IPCs: Shared Memory Objective To better understand the use of shared memory to communicate between processes. Description Inter Process Communication through shared memory is when two or more processes use a common block of memory to communicate. By writing to the shared memory segment, changes made by one process can be viewed by other processes. For a process to use shared memory, the following needs to be done: - Create a shared memory segment or use an already created shared memory segment (shmget()). A shared memory segment is identified through a numeric key (i.e. int). - Attach the shared memory segment to the process’s address space (shmat()) - When done, detach the shared memory segment from the process’s address space (shmdt()) - To perform control operations on a shared memory segment use (shmctl()) Check out the man pages for the following system calls: Submission: - One compressed file that contains all C and pdf files - Make sure to do the following: - Check the success of every system call you use 1. Simulate a producer and a consumer in a single program: Write a single C program where simple items (e.g. int) are produced and consumed. The user uses the keyboard to control the production and consumption of items by entering: - ‘p’: the program will produce an item if the buffer has empty space. If the buffer is full then the program prints a message. - ‘c’: the program to consume the oldest item in the buffer. If the buffer is empty then the program prints a message. - ‘0’: the program to terminate. Use a bounded buffer so the production part of the code will write to and the consumer part will read from. Production should be limited to the buffer size after which no new items should be produced. If the buffer is empty, then nothing can be consumed. To facilitate this, use 2 variables/pointers (in, out) to synchronize the use of the buffer: - When in = out: buffer is empty of new items, and reader should stop; - When in+1 = out: buffer is full, and writer should stop; int shmget(key_t key, size_t size, int flag); void * shmat(int shmid, const void *addr, int flag); int shmdt(const void *addr); int shmctl(int shmid, int cmd, struct shmid_ds *buf); http://man7.org/linux/man-pages/man2/shmget.2.html http://man7.org/linux/man-pages/man2/shmat.2.html http://man7.org/linux/man-pages/man2/shmdt.2.html http://man7.org/linux/man-pages/man2/shmctl.2.html Lab 10 CIS 370 Due: Week of 4/12/2021 Note: All labs are due before next week’s lab starts For more details on how production and the consumption can be synchronized, refer to slides 15-17 in “Lec_04_b Communication Between Processes “. Use the following structure in your code: #define MAX_SIZE 8 typedef struct bufferStruct { int in; int out; int content[MAX_SIZE];// will hold items produced (single int) }bufferStruct; It represents the bounded buffer and the 2 variables used synchronize production and consumption A sample run of the program Lab 10 CIS 370 Due: Week of 4/12/2021 Note: All labs are due before next week’s lab starts Ti m e 2. Using shared memory to communicate between a producer process and a consumer process: Extend part 1 above by writing 2 separate programs: a producer program and a consumer program. The producer program (produce.c) will produce simple items (e.g. int) and place them in a shared buffer. The consumer program (consume.c) will read these items and consume them (i.e. process them). Use the same data structure to represent the data that will be shared between the producer and the consumer processes: #define MAX_SIZE 8 typedef struct bufferStruct { int in; int out; int content[MAX_SIZE];// will hold ASCII code of characters }bufferStruct; Make sure the structure is saved in a separate header file buffer.h that you can include in your consume.c and produce.c files. The programs will run independently and will do the following: - produce.c: Every time the user hits enter in the producer process, it generates a random value (int) and stores it into the shared buffer until the buffer is full. If the user hits enter after that then a “buffer is full …” error message should be printed. - consume.c: Every time the user hits enter in the consumer process, it consumes the oldest item in the buffer and prints it to the screen, until the buffer is empty. If the user hits enter after that then a “buffer is empty …” error message should be printed. - Both programs should terminate if the user enters a ‘0’; More on IPCs: Shared Memory Objective Description Submission: Hmwr3 CIS 362 Empirical Methods in Computer Science Spring’21 Homework 3 March 31 Due April 14, 2021 Individual assignment! Total of 110 points. This homework assignment will test the concept of linear regression. You are provided with a data set. Teams 1, 4, 6, 8, 9, 12 will work with day.csv and Teams 2, 3, 5, 7, 10, 11 will work with hour.csv. Follow the guidelines of the two examples (ExampleAnalysis.pdf and ExampleRegression.pdf), but do not copy from the supplied documents, from each other or Internet. You are also provided with a sample Python code (CodewithExampleRegression.py). Note that this assignment must be completed with Python. Information on the dataset, attributes and necessary citation for the dataset is provided in Readme.txt. Problem: Analyze at least two pairs of attributes via linear regression method. Visualize the results and elaborate on the meaning of the uncovered relationships in the dataset and how are these related to the microcosm of the studied phenomenon. How to proceed: 1. The regression analysis should be focused on attributes exhibiting high correlation. In order to investigate that, develop attribute correlation matrix, heat map, density plots, box-plots and histograms (as shown in ExampleAnalysis.pdf). Each function/visualization must be supported by a short narrative to elaborate on the meaning of the function and possible deductions. The meaning of the attributes is also provided in Readme.txt. Don’t be shy to do additional research to facilitate your analysis. 2. Upon finding the best correlated pairs of attributes, conduct the regression analysis, visualize and analyze. All of the homework must be coded in Python (help file on the regression is provided). The homework must be formatted with Introduction, Method, Data set, Results - visualizations, interpretations, linear regressions and, finally, Conclusions (example file is provided of the format, albeit missing the attribute analysis - ExampleRegression.pdf). Grading: Attribute analysis - correlation matrix, heat map, box-plots and histograms – 20 points. Interpretations to the above – 20 points. Justification linear regression attribute pairs selection – 10 points. Two pairs of selected attributes regression – 20 points (10 points per pair.) Analysis of regression results, meanings and data set conclusions – 40 points (20 points per regression.) ========================================== Bike Sharing Dataset ========================================== Hadi Fanaee-T Laboratory of Artificial Intelligence and Decision Support (LIAAD), University of Porto INESC Porto, Campus da FEUP Rua Dr. Roberto Frias, 378 4200 - 465 Porto, Portugal ========================================= Background ========================================= Bike sharing systems are new generation of traditional bike rentals where whole process from membership, rental and return back has become automatic. Through these systems, user is able to easily rent a bike from a particular position and return back at another position. Currently, there are about over 500 bike-sharing programs around the world which is composed of over 500 thousands bicycles. Today, there exists great interest in these systems due to their important role in traffic, environmental and health issues. Apart from interesting real world applications of bike sharing systems, the characteristics of data being generated by these systems make them attractive for the research. Opposed to other transport services such as bus or subway, the duration of travel, departure and arrival position is explicitly recorded in these systems. This feature turns bike sharing system into a virtual sensor network that can be used for sensing mobility in the city. Hence, it is expected that most of important events in the city could be detected via monitoring these data. ========================================= Data Set ========================================= Bike-sharing rental process is highly correlated to the environmental and seasonal settings. For instance, weather conditions, precipitation, day of week, season, hour of the day, etc. can affect the rental behaviors. The core data set is related to the two-year historical log corresponding to years 2011 and 2012 from Capital Bikeshare system, Washington D.C., USA which is publicly available in http://capitalbikeshare.com/system-data. We aggregated the data on two hourly and daily basis and then extracted and added the corresponding weather and seasonal information. Weather information are extracted from http://www.freemeteo.com. ========================================= Files ========================================= - Readme.txt - hour.csv : bike sharing counts aggregated on hourly basis. Records: 17379 hours - day.csv - bike sharing counts aggregated on daily basis. Records: 731 days ========================================= Dataset characteristics ========================================= Both hour.csv and day.csv have the following fields, except hr which is not available in day.csv - instant: record index - dteday : date - season : season (1:springer, 2:summer, 3:fall, 4:winter) - yr : year (0: 2011, 1:2012) - mnth : month ( 1 to 12) - hr : hour (0 to 23) - holiday : weather day is holiday or not (extracted from http://dchr.dc.gov/page/holiday-schedule) - weekday : day of the week - workingday : if day is neither weekend nor holiday is 1, otherwise is 0. + weathersit : -
Answered 2 days AfterApr 13, 2021

Answer To: Lab 10 CIS 370 Due: Week of 4/12/2021 Note: All labs are due before next week’s lab starts More on...

Vicky answered on Apr 16 2021
144 Votes
# import libraries
import pandas as pd
import numpy as np
import scipy.stats as sc
import matplotlib.pyplot as plt
import sea
born as sns
# read hour.csv file
data = pd.read_csv('hour.csv')
# drop instant and dteday columns
data.drop(['instant','dteday'],axis=1,inplace=True)
# correlation matrix
print(data.corr())
# create heatmap of correlation matrix
sns.heatmap(data.corr())
# create histogram of all columns
data.hist(figsize=(15, 10))
# create scatter plot of all columns
sns.pairplot(data)
# create density plot of all columns
fig, axs = plt.subplots(3, 5)
fig.set_figheight(10)
fig.set_figwidth(15)
data['season'].plot.density(color='blue',ax=axs[0, 0])
axs[0, 0].set_title('season')
data['yr'].plot.density(color='orange',ax=axs[0, 1])
axs[0, 1].set_title('yr')
data['mnth'].plot.density(color='green',ax=axs[0, 2])
axs[0, 2].set_title('mnth')
data['hr'].plot.density(color='red',ax=axs[0, 3])
axs[0, 3].set_title('hr')
data['holiday'].plot.density(color='violet',ax=axs[0, 4])
axs[0, 4].set_title('holiday')
data['weekday'].plot.density(color='brown',ax=axs[1, 0])
axs[1, 0].set_title('weekday')
data['workingday'].plot.density(color='pink',ax=axs[1, 1])
axs[1, 1].set_title('workingday')
data['weathersit'].plot.density(color='grey',ax=axs[1, 2])
axs[1,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here