讲解:CS300、Program、java、javaSPSS|Python

CS300 Spring 2020Programming ProjectYou will complete a multithreaded two process system that communicates via System V messagequeues. The goal is to find the longest word that begins with the supplied prefix in a series of textpassages.Search Manager LogicSearch manager reads one or more prefixes from the command line, creates and sends prefix request messages(contains prefix string and prefix ID) via System V ipc queues and waits for the passage processor to return a seriesof responses. The search manager will print the results for each prefix as once all responses for that prefix havebeen received. Use the passage count on the first response to determine how many responses should be received.The search manager will send a message to passage processor letting the processor know that all the requestshave been sent and the passage processor can terminate once all responses have been sent. Once all theresponses are received, the search manager should terminate. Search manager will print a status of the requestswhen a SIGINT is received.Format:./searchmanager …./searchmanager 3 con pre worMessage(1): con Sent (8 bytes)Report conPassage 0 - Sense_And_Sensibility.txt - constantPassage 1 - Mansfield_Park.txt - contemptiblePassage 2 - The_Call_Of_The_Wild.txt! - no word foundPassage 3 - Tale_Of_Two_Cities.txt - no word foundPassage 4 - Peter_Pan.txt - conspicuousMessage(2): pre Sent (8 bytes)Report prePassage 0 - Sense_And_Sensibility.txt - no word foundPassage 1 - Mansfield_Park.txt - predictPassage 2 - The_Call_Of_The_Wild.txt! - no word foundPassage 3 - Tale_Of_Two_Cities.txt - preservesPassage 4 - Peter_Pan.txt - no word foundMessage(3): wor Sent (8 bytes)Report worPassage 0 - Sense_And_Sensibility.txt - no word foundPassage 1 - Mansfield_Park.txt - worldPassage 2 - The_Call_Of_The_Wild.txt1 - no word foundPassage 3 - Tale_Of_Two_Cities.txt - worstPassage 4 - Peter_Pan.txt - no word foundMessage(0): Sent (8 bytes)Exiting ...SIGINT captures Ctl-C to print status^C con – pendingpre – pendingwor – pending^C con – donepre – 3 of 5wor – pending** status before responsesreceived** status after con completes andduring pre responsesPassage Processor logicThe passage processor will read a series of passage file names from passages.txt. A thread will be created for eachpassage that builds Trie with words in the passage text, receives requests for longest word searches, searches thetrie for the longest word and asynchronously returns the longest word. The Passage Processor will read eachprefix request from the System V ipc queue using a Java Native Call, sends the requests to each worker, retrievesresponses from each worker and sends them back to the search manager via the system V queue. For each prefixrequest, the trie should be searched for the longest word that starts with that prefix. In the case that a word isfound, the longest word will be sent to the SearchManager via the System V ipc queue via a Java Native call. Theresponse will include the prefix id, the passage id, the passage name, the number of passages, present = 1, and thelongest word. In the case that the prefix is not found, the response will include the prefix id and present = 0.Format: java -cp . -Djava.library.path=./edu/cs300 edu.cs300.TextSamplesanderson@cs426: java -cp . -Djava.library.path=./edu/cs300 edu.cs300.TextSamples 2>/dev/nullWorker-0 (Sense_And_Sensibility.txt) thread started ...Worker-1 (Mansfield_Park.txt) thread started ...Worker-2 (The_Call_Of_The_Wild.txt) thread started ...Worker-4 (Peter_Pan.txt) thread started ...**prefix(1) con receivedWorker-2 1:con ==> not foundWorker-3 (Tale_Of_Two_Cities.txt) thread started ...Worker-3 1:con ==> not foundmsgsnd Reply 2 of 5 on 1:con from The_Call_Of_The_Wild.txt present=0 lw=----(len=4) msglen=144msgsnd Reply 3 of 5 on 1:con from Tale_Of_Two_Cities.txt present=0 lw=----(len=4) msglen=144Worker-1 1:con ==> contemptibleWorker-4 1:con ==> conspicuousmsgsnd Reply 1 of 5 on 1:con from Mansfield_Park.txt present=1 lw=contemptible(len=12) msglen=144msgsnd Reply 4 of 5 on 1:con from Peter_Pan.txt present=1 lw=conspicuous(len=11) msglen=144Worker-0 1:con ==> constantmsgsnd Reply 0 of 5 on 1:con from Sense_And_Sensibility.txt present=1 lw=constant(len=8)msglen=144**prefix(2) pre receivedWorker-2 2:pre ==> not foundWorker-0 2:pre ==> not foundmsgsnd Reply 2 of 5 on 2:pre from The_Call_Of_The_Wild.txt present=0 lw=----(len=4) msglen=144msgsnd Reply 0 of 5 on 2:pre from Sense_And_Sensibility.txt present=0 lw=----(len=4) msglen=144Worker-4 2:pre ==> not foundmsgsnd Reply 4 of 5 on 2:pre from Peter_Pan.txt present=0 lw=----(len=4) msglen=144Worker-1 2:pre ==> predictmsgsnd Reply 1 of 5 on 2:pre from Mansfield_Park.txt present=1 lw=predict(len=7) msglen=144Worker-3 2:pre ==> preservesmsgsnd Reply 3 of 5 on 2:pre from Tale_Of_Two_Cities.txt present=1 lw=preserves(len=9) msglen=144**prefix(3) wor receivedWorker-1 3:wor ==> worldWorker-3 3:wor ==> worstWorker-0 3:wor ==> not foundWorker-2 3:wor ==> not foundmsgsnd Reply 1 of 5 on 3:wor from Mansfield_Park.txt present=1 lw=world(len=5) msglen=144Worker-4 3:wor ==> not foundmsgsnd Reply 3 of 5 on 3:wor from Tale_Of_Two_Cities.txt present=1 lw=worst(len=5) msglen=144msgsnd Reply 0 of 5 on 3:wor from Sense_And_Sensibility.txt present=0 lw=----(len=4) msglen=144msgsnd Reply 2 of 5 on 3:wor from The_Call_Of_The_Wild.txt present=0 lw=----(len=4) msglen=144msgsnd Reply 4 of 5 on 3:wor from Peter_Pan.txt present=0 lw=----(len=4) msglen=144**prefix(0) receivedTerminating ...Search Manager requirements- Must be written in C- Numeric parameter denoting delay will be present and an integer; if it is zero, then use no delay- At least one prefix will be provided (may not be valid)- Only process prefixes are at least 3 characters should be processed- Only one prefix should be processed at a time. Once all the results on a prefix are returned, the next can besent to the passage processor- Send a prefix message with a zero id to notify the passage processor to completePassage processor requirements• Written in Java with the main function in edu.csCS300留学生作业代写、Program课程作业代做、java程序语言作业调试、java实验作业代写 代做SPSS|代写300.PassageProcessor.java• Read passage file names from passages.txt in root directory (hardcode the name)• Read contents of each passages file in the root directoryGeneral criteria• Programs will only be graded on cs426.ua.edu• Late submissions will not be accepted• Input criteria:o Prefixes-at least three characters long and no longer that 20 characterso Text Passages-Unlimited number of passageso Longest word-Maximum length 100 characterso Prefix Request -Unlimited number of requestso Text Processing-Ignore punctuation, only store words. Words with punctuation in them shouldbe ignored.o Passage Name should be the first 30 characters of the filename• The System V message queue requires an existing file and integer to create a unique queue name. You shouldcreate a file using your crimson id in your home directory. Use queue_ids.h header file to create a constantstring that holds the path to the queue and a constant integer to hold the day of your birthday. UseCRIMSON_ID and QUEUE_NUMBER in the ftok command to generate the identifier(see https://github.com/monicadelaine/Spring_cs300_project/blob/master/msgsnd_pr.c for an example)#define CRIMSON_ID /home/anderson/anderson#define QUEUE_NUMBER 12 //day of birth• Place files in the directory structure below (matches sample github).├── _passages.txt├── _Pride_And_Prejudice.txt├── _Mansfield_Park.txt.txt├── _The_Call_Of_The_Wild.txt├── _Tale_Of_Two_Cities.txt├── _Peter_Pan.txt├── _edu_cs300_MessageJNI.h├── _ queue_ids.h├── _longest_word_search.h├── _searchmanager.c├── _.c├── _.c├── _edu| └── cs300| └── SearchRequest.java| └── MessageJNI.java| └── ParallelTextSearch.java| └── Worker.java| └── PassageProcessor.java| └── .java├── _ CtCILibrary| ├── Trie.java| └── TrieNode.java└── _Makefile //if commands other than those provided are needed to build executables or dynamic library└── _readme.mdHints:• Use blocking msgrcv• Wrap search manager msgrcv in a while loop since SIGINT will cause the msgrcv to return with no message• Create two SIGINT handlers: one that gives a starting status that does not include any shared information anda 2nd handler that returns shared (protected) informationParameters- Minimize resource usage (do not hardcode any values other than given above)- Do not assume any ordering of the message retrieval- Maximize parallel processing- Appropriately protect data structures as needed- Minimize use of global variables (don’t use as a mechanism to avoid passing parameters)- Synchronize calls to msgsnd and msgrcv- Free any allocated memory; join any threads- Do not remove IPC queue when done- Message queue key should be your crimson id- Programs should be coded in C language (C99 standard) and will be compiled and tested oncs426.ua.edu. If you choose to program on another system, give yourself enough time verify it works oncs426. No other system will be used to test your code. May need _GNU_SOURCE switch.- You should use the pthreads library for threading. You can use mutexes or condition variables from thepthreads library and/or semaphores from the posix library.- Appropriate data structures should be selected based on your knowledge of data structures (CS201, etc).- Algorithms should be efficient and appropriate. This program should demonstrate not only yourunderstanding of process synchronization but your ability to design a program appropriately- No sleeps other than sleep between sending prefix requests driven by command line argument- Use #ifdef DEBUG to remove/add debug print statements based on compilation (-DDEBUG=0 or -DDEBUG=1)- Use standard error to print error messages- Use assert to check for unexpected conditionsGrading policyFailure to follow directions will result in point deductions. There are 70 students in this class. It isunreasonable to expect that any exceptions to the procedure will be made.Late assignments will not be accepted unless you have a doctor’s note covering the entire period fromFeb 28-Mar 23. The source code and test results should be printed and brought to class on Mar 23rd.Make sure your printout is easy to read (line wrapping etc). The source code should also be turned invia Blackboard (not emailed to me or the TA). Test results (using your generated data) should also beprinted and submitted via blackboard in pdf format. Test result submissions of any other type will not begraded.This is an individual assignment. The program must represent your own work. You can discuss high-levelconcepts. Do not show your code to anyone. I reserve the right to ask you about your program to discern ifyou indeed wrote the code. If you cannot explain your code and choices verbally, you may be turned in foracademic misconduct. All submissions will be analyzed to identify possible cases of cheating. Any cases ofsuspected collaboration will be referred to the College of Engineering Dean. A zero or low grade is alwaysbetter than having an academic misconduct on your academic record.** Programs will be evaluated based on many functional and design criteria **Sample criteria include:70% - functionality• Program contains the correct trie code to produce the output (find longest words in variety ofpassages)• Code for search manager contains correct functionality• Code for passage processor contains correct functionality• Hardcoding and lengths as specified• Signal catch implemented and working• Process sync correct (threads in PP and signals in SM)• Maximizes concurrency• Other functional or correctness features25% - design• Program exhibits defensible design choices in algorithms and data structures (if you add any)• Program does not contain extra loops or any code that hurts efficiency• Other design and efficiency features5% - style• Program must use appropriate and consistent style for naming of elements• Program must include reasonable whitespace and appropriate indentation• Program must include comments, especially in areas where you need to support your choices orwhere the purpose of the code is unclear.** Clarifications on the assignment will be posted to blackboard.转自:http://www.6daixie.com/contents/9/4956.html

你可能感兴趣的:(讲解:CS300、Program、java、javaSPSS|Python)