From a483b4b08b9be21624e3d7f3d84c9b2ca3407b63 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Wed, 9 Oct 2019 13:36:56 +0200 Subject: [PATCH] Assignment1: done Ex1 1-6 --- hw1/.gitignore | 344 +++++++++++++ hw1/Ex1/.idea/Ex1.iml | 12 + .../inspectionProfiles/Project_Default.xml | 11 + hw1/Ex1/.idea/misc.xml | 9 + hw1/Ex1/.idea/modules.xml | 8 + hw1/Ex1/.idea/vcs.xml | 6 + hw1/Ex1/.idea/workspace.xml | 464 ++++++++++++++++++ .../MultipleUpdatesPerThreadAtomic.java | 50 ++ .../atomic2/SingleUpdatePerThreadAtomic.java | 52 ++ hw1/Ex1/src/parallel/CollectingResults.java | 48 ++ hw1/Ex1/src/sequential/SequentialSum.java | 17 + .../src/simple1/MultipleUpdatesPerThread.java | 50 ++ .../src/simple2/SingleUpdatePerThread.java | 51 ++ .../MultipleUpdatesPerThreadSynch.java | 50 ++ .../SingleUpdatePerThreadSynch.java | 51 ++ hw1/Ex1/src/test/SumFunction.java | 6 + hw1/Ex1/src/test/Test.java | 84 ++++ hw1/Ex2/src/semaphore/Car.java | 25 + hw1/Ex2/src/semaphore/CarSimulation.java | 20 + hw1/Ex2/src/semaphore/Main.java | 23 + hw1/Ex2/src/semaphore/Queue.java | 20 + hw1/Ex2/src/semaphore/ValetQueue.java | 24 + hw1/Ex2/src/semaphore/ValetSimulation.java | 21 + .../reentrantrwlock/CreatorSimulation.java | 20 + hw1/Ex5/src/reentrantrwlock/Main.java | 49 ++ hw1/Ex5/src/reentrantrwlock/Movie.java | 26 + hw1/Ex5/src/reentrantrwlock/MovieCatalog.java | 66 +++ .../reentrantrwlock/PublisherSimulation.java | 16 + .../src/reentrantrwlock/ReaderSimulation.java | 34 ++ .../reentrantrwlock/WatcherSimulation.java | 20 + hw1/submission.tex | 32 ++ 31 files changed, 1709 insertions(+) create mode 100644 hw1/.gitignore create mode 100644 hw1/Ex1/.idea/Ex1.iml create mode 100644 hw1/Ex1/.idea/inspectionProfiles/Project_Default.xml create mode 100644 hw1/Ex1/.idea/misc.xml create mode 100644 hw1/Ex1/.idea/modules.xml create mode 100644 hw1/Ex1/.idea/vcs.xml create mode 100644 hw1/Ex1/.idea/workspace.xml create mode 100644 hw1/Ex1/src/atomic1/MultipleUpdatesPerThreadAtomic.java create mode 100644 hw1/Ex1/src/atomic2/SingleUpdatePerThreadAtomic.java create mode 100644 hw1/Ex1/src/parallel/CollectingResults.java create mode 100644 hw1/Ex1/src/sequential/SequentialSum.java create mode 100644 hw1/Ex1/src/simple1/MultipleUpdatesPerThread.java create mode 100644 hw1/Ex1/src/simple2/SingleUpdatePerThread.java create mode 100644 hw1/Ex1/src/synchronized1/MultipleUpdatesPerThreadSynch.java create mode 100644 hw1/Ex1/src/synchronized2/SingleUpdatePerThreadSynch.java create mode 100644 hw1/Ex1/src/test/SumFunction.java create mode 100644 hw1/Ex1/src/test/Test.java create mode 100644 hw1/Ex2/src/semaphore/Car.java create mode 100644 hw1/Ex2/src/semaphore/CarSimulation.java create mode 100644 hw1/Ex2/src/semaphore/Main.java create mode 100644 hw1/Ex2/src/semaphore/Queue.java create mode 100644 hw1/Ex2/src/semaphore/ValetQueue.java create mode 100644 hw1/Ex2/src/semaphore/ValetSimulation.java create mode 100644 hw1/Ex5/src/reentrantrwlock/CreatorSimulation.java create mode 100644 hw1/Ex5/src/reentrantrwlock/Main.java create mode 100644 hw1/Ex5/src/reentrantrwlock/Movie.java create mode 100644 hw1/Ex5/src/reentrantrwlock/MovieCatalog.java create mode 100644 hw1/Ex5/src/reentrantrwlock/PublisherSimulation.java create mode 100644 hw1/Ex5/src/reentrantrwlock/ReaderSimulation.java create mode 100644 hw1/Ex5/src/reentrantrwlock/WatcherSimulation.java create mode 100644 hw1/submission.tex diff --git a/hw1/.gitignore b/hw1/.gitignore new file mode 100644 index 0000000..cd70864 --- /dev/null +++ b/hw1/.gitignore @@ -0,0 +1,344 @@ +*.pdf + +## Core latex/pdflatex auxiliary files: +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.fmt +*.fot +*.cb +*.cb2 +.*.lb + +## Intermediate documents: +*.dvi +*.xdv +*-converted-to.* +# these rules might exclude image files for figures etc. +# *.ps +# *.eps +# *.pdf + +## Generated if empty string is given at "Please type another file name for output:" +.pdf + +## Bibliography auxiliary files (bibtex/biblatex/biber): +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.run.xml + +## Build tool auxiliary files: +*.fdb_latexmk +*.synctex +*.synctex(busy) +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync + +## Build tool directories for auxiliary files +# latexrun +latex.out/ + +## Auxiliary and intermediate files from other packages: +# algorithms +*.alg +*.loa + +# achemso +acs-*.bib + +# amsthm +*.thm + +# beamer +*.nav +*.pre +*.snm +*.vrb + +# changes +*.soc + +# comment +*.cut + +# cprotect +*.cpt + +# elsarticle (documentclass of Elsevier journals) +*.spl + +# endnotes +*.ent + +# fixme +*.lox + +# feynmf/feynmp +*.mf +*.mp +*.t[1-9] +*.t[1-9][0-9] +*.tfm + +#(r)(e)ledmac/(r)(e)ledpar +*.end +*.?end +*.[1-9] +*.[1-9][0-9] +*.[1-9][0-9][0-9] +*.[1-9]R +*.[1-9][0-9]R +*.[1-9][0-9][0-9]R +*.eledsec[1-9] +*.eledsec[1-9]R +*.eledsec[1-9][0-9] +*.eledsec[1-9][0-9]R +*.eledsec[1-9][0-9][0-9] +*.eledsec[1-9][0-9][0-9]R + +# glossaries +*.acn +*.acr +*.glg +*.glo +*.gls +*.glsdefs +*.lzo +*.lzs + +# uncomment this for glossaries-extra (will ignore makeindex's style files!) +# *.ist + +# gnuplottex +*-gnuplottex-* + +# gregoriotex +*.gaux +*.gtex + +# htlatex +*.4ct +*.4tc +*.idv +*.lg +*.trc +*.xref + +# hyperref +*.brf + +# knitr +*-concordance.tex +# TODO Comment the next line if you want to keep your tikz graphics files +*.tikz +*-tikzDictionary + +# listings +*.lol + +# luatexja-ruby +*.ltjruby + +# makeidx +*.idx +*.ilg +*.ind + +# minitoc +*.maf +*.mlf +*.mlt +*.mtc[0-9]* +*.slf[0-9]* +*.slt[0-9]* +*.stc[0-9]* + +# minted +_minted* +*.pyg + +# morewrites +*.mw + +# nomencl +*.nlg +*.nlo +*.nls + +# pax +*.pax + +# pdfpcnotes +*.pdfpc + +# sagetex +*.sagetex.sage +*.sagetex.py +*.sagetex.scmd + +# scrwfile +*.wrt + +# sympy +*.sout +*.sympy +sympy-plots-for-*.tex/ + +# pdfcomment +*.upa +*.upb + +# pythontex +*.pytxcode +pythontex-files-*/ + +# tcolorbox +*.listing + +# thmtools +*.loe + +# TikZ & PGF +*.dpth +*.md5 +*.auxlock + +# todonotes +*.tdo + +# vhistory +*.hst +*.ver + +# easy-todo +*.lod + +# xcolor +*.xcp + +# xmpincl +*.xmpi + +# xindy +*.xdy + +# xypic precompiled matrices and outlines +*.xyc +*.xyd + +# endfloat +*.ttt +*.fff + +# Latexian +TSWLatexianTemp* + +## Editors: +# WinEdt +*.bak +*.sav + +# Texpad +.texpadtmp + +# LyX +*.lyx~ + +# Kile +*.backup + +# gummi +.*.swp + +# KBibTeX +*~[0-9]* + +# auto folder when using emacs and auctex +./auto/* +*.el + +# expex forward references with \gathertags +*-tags.tex + +# standalone packages +*.sta + +# Makeindex log files +*.lpz + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/hw1/Ex1/.idea/Ex1.iml b/hw1/Ex1/.idea/Ex1.iml new file mode 100644 index 0000000..b319ae2 --- /dev/null +++ b/hw1/Ex1/.idea/Ex1.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/hw1/Ex1/.idea/inspectionProfiles/Project_Default.xml b/hw1/Ex1/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..d700f20 --- /dev/null +++ b/hw1/Ex1/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/hw1/Ex1/.idea/misc.xml b/hw1/Ex1/.idea/misc.xml new file mode 100644 index 0000000..0c31c09 --- /dev/null +++ b/hw1/Ex1/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/hw1/Ex1/.idea/modules.xml b/hw1/Ex1/.idea/modules.xml new file mode 100644 index 0000000..2f08044 --- /dev/null +++ b/hw1/Ex1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/hw1/Ex1/.idea/vcs.xml b/hw1/Ex1/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/hw1/Ex1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/hw1/Ex1/.idea/workspace.xml b/hw1/Ex1/.idea/workspace.xml new file mode 100644 index 0000000..dd7563b --- /dev/null +++ b/hw1/Ex1/.idea/workspace.xml @@ -0,0 +1,464 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +