辅导案例-CSCI 3120 -Assignment 1

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
1
CSCI 3120 Operating Systems

Assignment 1: A Simple C Program for Linux

Due: 16:30, Sept. 25, 2020

- Teaching Assistants:
o Nathaniel Brown ([email protected])
o Di Yang ([email protected])
o Patricia Kibenge-MacLeod ([email protected])
o Hui Huang ([email protected])
o Piyush Piyush ([email protected])
- Help Hours via the Channel “Office Hour - TAs” on MS Teams:
o Monday: 9am-10am, Hui Huang
o Tuesdays: 7pm-8pm, Di Yang
o Wednesday: 9am-10am, Patricia Kibenge-MacLeod
o Thursday: 7pm-8pm, Nathaniel Brown
o Friday: 12pm-1pm, Piyush Piyush


1. Assignment Overview In this assignment, you need to design and implement a C program that prompts the user to enter a sentence, splits the sentence into multiple words, then displays the words on the screen and places the words in a new file. Your program will be tested on the undergraduate server “timberlea.cs.dal.ca”, which is a Linux machine.
2. Important Information There is a zero-tolerance policy on academic offenses such as plagiarism or inappropriate collaboration. By submitting your solution for this assignment, you acknowledge that the code submitted is your own work. You also agree that your code may be submitted to a plagiarism detection software (such as MOSS) that may have servers located outside Canada unless you have notified me otherwise, in writing, before the submission deadline. Any suspected act of plagiarism will be reported to the Faculty’s Academic Integrity Officer in accordance with Dalhousie University’s regulations regarding Academic Integrity. Please note that: 1) The assignments are individual assignments. You can discuss the problems with your friends/classmates, but you need to write your program by yourself. There should not be much similarity in terms of coding. 2) When you refer to some online resources to complete your program, you need to understand the mechanism, then write your own code. In addition, you should cite the sources via comments in your program.
2

3. Detailed Requirements 1) Overview: In this assignment, you need to design and implement a C program that prompts the user to enter a sentence, splits the sentence into multiple words, then displays the words on the screen and places the words in a new file. The following steps should be implemented in your program:
Step 1: Prompt Displaying: When your program is executed, the following prompt should be displayed on the screen, asking the user to enter a sentence. Then the user could enter a sentence on the same line. The user sentence is composed of multiple words. There is only one space between neighboring words.
Please Enter Your Sentence:
Step 2: Input Processing: After the user enters a sentence and presses the return key, your program receives the input and splits the user input into multiple words. Then the words are displayed on the screen. Note that there should be only one word in each line. In addition, the order of the words in the user input should be preserved. For example, if the user enters “We all like computer science”, then the word “We” should appear in the first line and the word “all” should appear in the second line, etc.
Step 3: File Creation: Thereafter, your program needs to create a new file named “Output.txt”. You can assume that no file named “Output.txt” exists in the same directory as your program.
Step 4: Output Processing: Once the file “Output.txt” is created, your program will put the words that were obtained previously in the file. Note that there is only one word in each line. In addition, the order of the words in the user input should be preserved. For example, if the user enters “We all like computer science”, then the word “We” should appear in the first line of “Output.txt” and the word “all” should appear in the second line, etc.
Please note that: a) “timberlea.cs.dal.ca” is the computer used by the TA to evaluate your program. Therefore, you need to make sure that your program works on timberlea. a. You can use your CS ID to log on to “timberlea.cs.dal.ca” in order to write your program. Alternatively, you can write your program on other machines, then transfer your program to timeberlea and thereafter test it on timberlea. b. If you do not know your CS ID, you can visit the following webpage to get your CS ID. If your CS ID does not work or you have a question about your CS ID, please send an email to “[email protected]”. https://csid.cs.dal.ca/
b) Essentially, the user input is a series of characters with the new line character (i.e. ‘\n’) at the end. There are a variety of different methods that you can use to get the user input. Here are two simple methods:
3
a. read(): The following link discusses the details. http://man7.org/linux/man-pages/man3/read.3p.html
b. fgets(): The following link discusses the details. Please note that the document includes “STDIN”, but we should use “stdin” instead of “STDIN” on timberlea. https://www.asc.ohio-state.edu/physics/ntg/780/handouts/interactive_input_in_C.pdf c) User input splitting: There are a variety of different ways to parse user input and generate the required words. One simple way is to utilize “strtok()”. Here are two links about this function: a. http://man7.org/linux/man-pages/man3/strtok.3.html b. http://www.cplusplus.com/reference/cstring/strtok/ Note that strtok() breaks a string into a sequence of zero or more nonempty tokens. On the first call to strtok(), the string to be parsed should be specified as a parameter. In each subsequent call that parses the same string, the corresponding parameter must be NULL.
d) Here are two useful webpages, which discuss C strings and how to use an array of pointers to character to store a list of strings: a. https://www.cs.bu.edu/teaching/c/string/intro/ b. https://www.tutorialspoint.com/cprogramming/c_array_of_pointers.htm e) Your program must use the GNU C library (i.e. glibc) to implement the required features. Here are a few links about glibc: a. https://www.gnu.org/software/libc/documentation.html b. https://www.kernel.org/doc/man-pages/ c. http://man7.org/linux/man-pages/index.html f) Compiling and running your program on timberlea.cs.dal.ca should not lead to errors or warnings. To compile and run your program on timberlea, you need to be able to upload a file to or download a file from timberlea. The following webpage includes a tutorial on timberlea downloading/uploading. Note that the example computer used in the tutorial is bluenose.cs.dal.ca (which is the old undergraduate server). You should use “timberlea.cs.dal.ca” in this assignment. https://web.cs.dal.ca/~society/#/ 2) Readme File: You need to complete a readme file named “Readme.txt”, which includes the instructions that the TA could use to compile and execute your program on timberlea. 3) Submission: Please pay attention to the following submission requirements: a) You should place “Readme.txt” in the directory where your program files are located. b) Your program files and “Readme.txt” should be compressed into a zip file named “YourFirstName-YourLastName-ASN1.zip”. For example, my zip file should be called “Qiang-Ye-ASN1.zip”. c) Finally, you need to submit your zip file for this assignment via brightspace. Note that there is an appendix at the end of this document, which includes the commands that you can use to compress your files on timberlea. In addition, there is another appendix, which illustrates how to view and kill your processes on timberlea.

4
4. Grading Criteria The TA will use your submitted zip file to evaluate your assignment. The full grade is 10 points. The details of the grading criteria are presented as follows.
• “Readme.txt” with the correct compilation/execution instructions is provided. [1 Point]
• Prompt Displaying: When your program is executed, the following prompt should be displayed on the screen, asking the user to enter a sentence. Then the user could enter a sentence on the same line. [1 Points]
• Input Processing: After the user enters a sentence and presses the return key, your program receives the input and splits the user input into multiple words. Then the words are displayed on the screen. [4 Points]
• File Creation: Thereafter, your program needs to create a new file named “Output.txt”. [1 Points]
• Output Processing: Once the file “Output.txt” is created, your program will put the words that were obtained previously in the file. Note that there is only one word in each line. In addition, the order of the words in the user input should be preserved. [2 Points]
• Proper programming format/style (e.g. proper indentation, proper variable names, proper comments, release the memory that is dynamically allocated when it is not needed any more, etc.). [1 Point] Please note that when “Readme.txt” is not provided or “Readme.txt” does not include the compilation/execution instructions, your submission will be compiled using the standard command gcc -o A1 A1.c (or your filename), and you will receive a zero grade if your program cannot be successfully compiled on timberlea. 5. Academic Integrity At Dalhousie University, we respect the values of academic integrity: honesty, trust, fairness, responsibility and respect. As a student, adherence to the values of academic integrity and related policies is a requirement of being part of the academic community at Dalhousie University.
1) What does academic integrity mean? Academic integrity means being honest in the fulfillment of your academic responsibilities thus establishing mutual trust. Fairness is essential to the interactions of the academic community and is achieved through respect for the opinions and ideas of others. Violations of intellectual honesty are offensive to the entire academic community, not just to the individual faculty member and students in whose class an offence occur (See Intellectual Honesty section of University Calendar).
2) How can you achieve academic integrity? - Make sure you understand Dalhousie’s policies on academic integrity.
5
- Give appropriate credit to the sources used in your assignment such as written or oral work, computer codes/programs, artistic or architectural works, scientific projects, performances, web page designs, graphical representations, diagrams, videos, and images. Use RefWorks to keep track of your research and edit and format bibliographies in the citation style required by the instructor. (See http://www.library.dal.ca/How/RefWorks) - Do not download the work of another from the Internet and submit it as your own. - Do not submit work that has been completed through collaboration or previously submitted for another assignment without permission from your instructor. - Do not write an examination or test for someone else. - Do not falsify data or lab results. These examples should be considered only as a guide and not an exhaustive list.
3) What will happen if an allegation of an academic offence is made against you? I am required to report a suspected offence. The full process is outlined in the Discipline flow chart, which can be found at: http://academicintegrity.dal.ca/Files/AcademicDisciplineProcess.pdf and includes the following: a. Each Faculty has an Academic Integrity Officer (AIO) who receives allegations from instructors. b. The AIO decides whether to proceed with the allegation and you will be notified of the process. c. If the case proceeds, you will receive an INC (incomplete) grade until the matter is resolved. d. If you are found guilty of an academic offence, a penalty will be assigned ranging from a warning to a suspension or expulsion from the University and can include a notation on your transcript, failure of the assignment or failure of the course. All penalties are academic in nature.
4) Where can you turn for help?
- If you are ever unsure about ANYTHING, contact myself. - The Academic Integrity website (http://academicintegrity.dal.ca) has links to policies, definitions, online tutorials, tips on citing and paraphrasing. - The Writing Center provides assistance with proofreading, writing styles, citations. - Dalhousie Libraries have workshops, online tutorials, citation guides, Assignment Calculator, RefWorks, etc. - The Dalhousie Student Advocacy Service assists students with academic appeals and student discipline procedures. - The Senate Office provides links to a list of Academic Integrity Officers, discipline flow chart, and Senate Discipline Committee.
6
Appendix 1: How to Use Zip and Unzip on Timberlea



Appendix 2: How to View/Kill Your Processes on Timberlea

Due to programming mistakes, you might leave a number of running processes on timberlea.
When you leave too many running processes timberlea, your timberlea account could be locked
temporarily (then you need to talk to CS Help to unlock your account). To view/kill your
processes on timberlea, you can use the following commands. Please keep an eye on your
processes on timberlea.
1) Command to display the processes belonging to a specific ID (i.e. UID): ps -u UID
2) Command to kill a process using process ID (i.e. PID): kill -9 PID
3) Command to kill all processed belonging to a specific user ID (i.e. UID): pkill -u UID
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468