写作SCC.211编程课程、web程序设计程序 写作

” 写作SCC.211编程课程、web程序设计程序 写作Week 4 CourseworkThis document outlines the coursework for the first half of SCC.211. Before providing details somereminders pertaining to the coursework:1) You must submit your coursework onto Moodle before demoing.2) We will be unable to provide support in Week 5 labs, which are dedicated to solely marking. Iwill be running evening sessions in Week 4 this is your best chance to seek clarification onthe exercise.3) You are not allowed to Use any pre-existing concurrency libraries doing so will result in anautomatic fail on any submitted coursework. Using operations that hide the complexity ofthe underlying concurrency primitive makes it impossible for us to determine whether youfully understand what is occurring. If you are unsure what this entails let me know ASAP.4) Part of your marks will be based on appropriate use of classes, commenting, and formatting.Make sure that the editor which displays your code formats correctly.5) Further details on the grading criteria can be found in the marking guidelines document.Programming ExerciseYou will be working with the files found under WK4_coursework, which are incomplete and will notcompile. This program shares similar functionality to the one provided in Week 3.In this program X users Will add elements onto a single buffer object, which are removed by Ywebservers. The number of users, webservers and elements are all specified by user input, andresembles the following:Enter buffer capacity20Enter number of users10Enter number of servers10Enter number of total elements100The program must automatically divide the number of inputted elements evenly across all users (evenfor odd values), While webservers attempt to remove elements from the buffer as evenly as possible.The action of adding and removing elements from the buffer must be performed concurrently, andwill resemble the following in mid execution:User 8 adds an element 1/20User 6 adds an element 2/20User 9 adds an element 3/20User 0 adds an element 4/20Serv 2 removed element 3/20User 1 adds an element 4/20Serv 5 removed element 3/20Serv 6 removed element 2/20The program must also continue to operate even if the buffer is empty or full, with the user orwebserver waiting until the buffer is again available. An example of this will resemble the followingwhen the buffer is empty:Serv 6 removed element 2/20Serv 3 removed element 1/20Serv 2 removed element 0/20Buffer empty web server waitBuffer empty web server waitUser 2 added an element 1/20User 6 added an element 2/20And will resemble the following when the buffer is full:User 9 added an element 19/20User 5 added an element 20/20Buffer full User now sleepingServ 1 removed element 19/20User 8 added an element 20/20Buffer full User now sleepingBuffer full User now sleepingServ 2 removed element 19/20Once all users and server have completed processing all elements, the program should outputsomething resembling the following:———————–User 7 created a total of 10 elementsUser 5 created a total of 10 elementsUser 0 created a total of 10 elementsUser 6 created a total of 10 elementsUser 8 created a total of 10 elementsUser 1 created a total of 10 elementsUser 2 created a total of 10 elementsUser 3 created a total of 10 elementsUser 9 created a total of 10 elementsUser 4 created a total of 10 elementsConsumer 9 consumed a total of 10 elementsConsumer 1 consumed a total of 10 elementsConsumer 3 consumed a total of 10 elementsConsumer 6 consumed a total of 10 elementsConsumer 4 consumed a total of 10 elementsConsumer 0 consumed a total of 10 elementsConsumer 7 consumed a total of 10 elementsConsumer 2 consumed a total of 10 elementsConsumer 5 consumed a total of 10 elementsConsumer 8 consumed a total of 10 elementsAs well as check that the buffer is empty, and that all created threads have completed:———————–Buffer has 0 elements remaining———————–Program took 10052 milliseconds to completePlease note that the time does not need to be exactly the same this will be entirely dependent onthe number of elements processed by user defined values for users and webservers.Your assignment is to make this program function correctly allowing for concurrent access betweenusers and servers on a single buffer. You must demonstrate to us that the program will operate in athread-safe manner under the following scenarios:1) Program Correctly operated under any scale of buffer size, number of users, web servers, andelements2) Buffer is Frequently empty (i.e. web servers removes elements faster than users add)3) Buffer is frequently full (i.e. users adds elements faster than web servers remove)To demonstrate 2 and 3 I would advise that you use the java thread sleep method on users and webservers to Control their execution. However do be advised that we will likely be asking you to disablingthread sleep for actual demonstration, so many sure you test your code without it.Important: You are NOT allowed to use the synchronized keyword within any of your methodsEXCEPT within synchronization primitive classes that you have designed yourself (i.e. semaphores,locks). This is to allow us to ask questions for you to demonstrate understanding on concurrencyconcepts.When you are ready to demo, myself or one of the TAs will sign off your work.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导