首页 > 其他分享 >CSSE7610  The algorithm  exclusive acces

CSSE7610  The algorithm  exclusive acces

时间:2024-09-07 20:24:45浏览次数:3  
标签:exclusive algorithm buffer acces should CSSE7610 file marks your

CSSE7610               Assignment 1

1.  A bounded buffer is frequently implemented as a circular buffer, which is an array that is indexed modulo its length:

 

One variable, in, contains the index of the first empty space and an- other, out, the index of the first full space (if any). If in > out, there is data in buffer[out..in-1]; if in < out, there is data in buffer[out..N-1] and buffer[0..in-1]; if in = out, the buffer is empty. Consider the following algorithm for two processes sharing a circular buffer:

 

Assume that useItem(d) always runs to completion, but that getItem() may not terminate since there may be no items available.

(a)  The algorithm is intended to provide mutually exclusive access to individual elements of the array. That is, when  p is able to write a value to the array, q should not be able to read from the same array index.  State this property as an invariant and prove it using induction. You may need to prove other invariants to do this.

(b)  The algorithm is also intended to provide freedom from starvation for each process. That is, after getting an item process p  should eventually write it to the buffer, and when an item is in the buffer process  q should eventually read it. State these properties  using temporal logic and prove they are correct. You may need to prove further invariants to do this.

Deliverable:  A file circular.pdf containing your answers to (a) and (b), and your name and student number.

2.  Check the  above algorithm for any lines which contain more than one critical reference.

(a) Write a Promela specification f代 写CSSE7610  The algorithm  exclusive accesor the algorithm that does not have more than one critical reference in any atomic statement. Note that the modulo operator in Promela is % (as in C and Java).

(b)  Use Spin to prove that the algorithm is correct:  use assertions to prove mutual exclusion, and an LTL property to prove freedom from starvation. You may need to introduce additional (auxiliary) vari- ables to do this.

Deliverable: A file circular.pml containing the Promela specification, and a comment describing any changes you made to avoid lines with more than one critical reference, the properties you proved, and your name and student number.

3. Write a Java program to format an arbitrary text file to have exactly 80 characters per line (except for the last line which may have 80 or less char- acters), after replacing all occurrences of tabs and two or more consecutive spaces with a single space. Your program must use three threads running concurrently. The first thread reads characters from the input file using the provided class A1Reader, and replaces end-of-line characters with spaces. The second thread removes and replaces tabs and removes consecutive occurrences of spaces, and the third thread writes lines of 80 characters to the output file using the provided class A1Writer. The threads must communicate characters via circular buffers of length 20 characters using the algorithm from question 1.

The three threads should be started by the main thread of your Java program. Your program should use cooperative multitasking, i.e., a thread should allow others to proceed when it can do no useful work but not otherwise, and it should terminate gracefully, i.e., all threads should reach the end of their run methods.

Deliverables:  A zip file containing a file FileConverter.java  with your main method for the program, along with all supporting source (.java) files (apart from A1Reader and A1Writer), and a file readme.txt describing (in a few paragraphs) the approach you have taken to coding your program and providing a list of all your classes and their roles. All files should be well-documented and contain your name and student number (as a comment).

Important:  For testing purposes,  it is a requirement that you use the provided A1Reader and A1Writer classes. It is also important that you do not modify the provided classes.  Also, do not make your submitted files dependent on being in a particular package. That is, remove any lines:

package packageName;

Marking criteria

Marks will be given for the correctness and readability of answers to questions 1 to 3 as follows.  As part of the marking process, you may be required to meet with the teaching team after your assignment submission. In this meeting, you will discuss the work you have submitted, explain your solution, and answer questions regarding your submission.

Students failing to explain their submission or attend this meeting will receive a grade of ZERO for this assignment.

Question 1 (10 marks)

● Proof of mutual exclusion                                                              (5 marks)

● Proofs of starvation freedom                                                          (5 marks)

Question 2 (5 marks)

● Promela specification of algorithm                                               (3 marks)

● Proof method for mutual exclusion                                               (1 mark)

● Proof method for starvation freedom                                             (1 mark)

Question 3 (10 marks)

● Java classes modelling threads and buffers                                    (7 marks)

● Program producing correct behaviour                                           (2 mark)

● readme file                                                                                         (1 mark)

 

标签:exclusive,algorithm,buffer,acces,should,CSSE7610,file,marks,your
From: https://www.cnblogs.com/qq--99515681/p/18402112

相关文章

  • fatal: unable to access 'https://aomedia.googlesource.com/aom.git/': Failed to c
     低版本的Mac安装PHP就是受罪brewinstallshivammathur/php/[email protected]:YouareusingmacOS11.We(andApple)donotprovidesupportforthisoldversion.Itisexpectedbehaviourthatsomeformulaewillfailtobuildinthisoldversion.Itisexpec......
  • Error: xz: undefined method `deny_network_access!' for Formulary::FormulaNamespa
      ==>Fetchingxz==>Downloadinghttps://raw.githubusercontent.com/Homebrew/homebrew-core/c7f385112a4c2b9eed76b346d11d333fa8954a89/Formula/x/xz.rbAlreadydownloaded:/Users/wboll/Library/Caches/Homebrew/downloads/049af374432798d3b924a0d36bdcd6......
  • android AccessibilityService合法合规采集大众点评app商店商品详情(2024-09-02)
    免责任声明:任何可操作性的内容与本人无关,文章内容仅供参考学习,如有侵权损害贵公司利益,请联系作者,会立刻马上进行删除。一、原理介绍1、打开大众点评app商店publicvoidopen_shop(Contextcontext,Stringshop_id){Stringurl="dianping://gcshopshell?shop......
  • android AccessibilityService合法合规增加小红书笔记曝光阅读量(2024-09-02)
    免责任声明:任何可操作性的内容与本人无关,文章内容仅供参考学习,如有侵权损害贵公司利益,请联系作者,会立刻马上进行删除。一、分析目前可增加曝光阅读流量渠道入口(完成)1.发现页打开小红书app选择顶部发现页(完成)2.搜索页打开小红书app点击右上角搜索,进入搜索结果页(完成)3.......
  • php获取微信access_token
    参考代码:新建一个php文件,将下面代码拷贝进去,替换自己的appid和appSecret<?php//检查是否是GET请求if($_SERVER['REQUEST_METHOD']=='GET'){echogetAccessToken();}functiongetAccessToken(){$appId='替换';//微信小程序的AppID$appSecret=......
  • 有没有办法通过 PHP 或 .htaccess 来区分资源请求者
    是的,你可以通过PHP或.htaccess来区分资源请求者。在PHP中,你可以使用$_SERVER['REMOTE_ADDR']变量来获取请求者的IP地址。你还可以使用其他变量来获取更多关于请求者的信息,例如$_SERVER['HTTP_USER_AGENT']来获取请求者的浏览器信息。在.htaccess中,你可以使用RewriteCo......
  • nginx日志分析工具goaccess
    nginx日志分析工具goaccess wgethttp://tar.goaccess.io/goaccess-1.2.tar.gztarxfgoaccess-1.2.tar.gzcdgoaccess-1.2/./configure--enable-utf8--enable-geoip=legacymakemakeinstall报错:  ......
  • WPF access mysql and pass data from datagrid to mysql
    //sqldropdatabaseifexistsmydb;createdatabasemydb;usemydb;droptableifexistsmt;createtablemt(idintauto_incrementprimarykey,namevarchar(50)notnulldefault'',isbnvarchar(50)notnulldefault'',authorvarchar......
  • PHP 预定义类 ArrayAccess接口的使用
    1何为预定义php中的预定义是指的是被视为全局可用的内置常量、变量、函数、类、接口,这些内容不需要特别的引入或申明,本身就存在于php语言中。php预定义类目录:https://www.php.net/manual/zh/reserved.classes.php2 ArrayAccess接口简介ArrayAccess接口可以让你在操纵对象......
  • Docker Push Error "denied: requested access to the resource is denied": 终极解决
    预览版:终极解决方案——把库删了,再重新建一个名字一样的,然后push一般dockerlogin登录之后,sudodockerpushusername/dockername:latest就能成功push了。然后我还是有报错:xxxxxxxxxxxx:Preparingxxxxxxxxxxxx:Preparingxxxxxxxxxxxx:Preparingxxxxxxxxxxxx:Preparing......