You will modify your program from Assignment #2 to simulate a function call stack, implemented as a linked list of frames, using C in the Ubuntu Linux environment.In this assignment, you will: define the data types and structures required to represent the function call stack as a linked list of frames write supporting functions to manage the function call stack modify the instrumentation functions to work with the call stack implemented as a linked list change the existing call stack output functions to print to a file instead of standard outputLearning Objectives perform more complex pointer manipulations by implementing a linked list work with dynamically allocated memory practice using double pointers in pass-by-reference parameter passing use file I/O function calls to output to a file Note: Of course, linked lists are not the best underlying data structure for representing a stack. The use of linked lists in this assignment is for exclusively pedagogical purposes.Instructions1. Data typesModify the function call stack data type, so that the call stack is implemented as a singly linked list of frames, exactly as we saw in the Advanced Linked Lists section of the course notes: StackType corresponds to the function call stack and contains a pointer to the head of the linked list of frames FrameNodeType represents a node in the linked list your main function must define the function call stack as dynamically allocated memoryo there must be only one instance of the function call stack in the entire program; do not make copies!o this is not a global variableNotes: your program must use the definitions in the header file found here: a3Defs.h the header file declares a frame number in each frame; your program must initialize this value2. Supporting stack functionsImplement the following support functions for the function call stack: initStack allocates and initializes the stack push adds a frame in LIFO order to the call stack pop removes from the stack the frame that was last added cleanupStack deallocates all the memory for the stackNote: remember to manage your memory! do not leave any memory leaksCOMP 2401 Assignment #3 Fall 2013 2/33. Instrumentation functionsModify both enterSumFunc and leaveSumFunc functions to manipulate the function call stack as a linked list: enterSumFunc is called when a sum function begins; it must:o create a new dynamically allocated stack frame to store information about one of the sum functionso initialize all the frame data, as you did in Assignment #2o add the new frame to the function call stacko output the contents of the call stack, using the modified dumpStack function leaveSumFunc is called when a sum function returns; it must:o output the contents of the call stack, using the modified dumpStack functiono remove the corresponding frame from the stackNotes: your sum functions must call the instrumentation functions defined above the instrumentation functions must use the supporting push and pop functions4. Stack output to fileDefine, as a global variable, a pointer to the output file that will contain the contents of the call stack remember! global variables are to be used very rarely, this is a one-time exception!Modify the call stack output functions to work with the linked list and output the contents of the stack to a file: dumpStack traverses the linked list of frames and outputs the contents to the output fileo you must use the same output format as in Assignment #2 dumpVar and dumpBytes must be modified to print to file as wellNotes: think about where you must open and close the output file! you must use the stack utility functions found here: a3Stack.c you can find some helpful sample code here: testUtil.cConstraints Design:o you must separate your code into modular, reusable functionso never use global variables, unless otherwise instructedo compound data types must be passed by reference, not by valueo you must manage your memory! use valgrind to find memory leaks Reuse:o you must include the given header file in your program and use its function prototypes exactly as defined Implementation:o your program must perform all basic error checkingo it must be thoroughly commented Executiono programs that do not compile, do not execute, or violate any constraint are subject to severe deductionsCOMP 2401 Assignment #3 Fall 2013 3/3SubmissionYou will submit in cuLearn, before the due date and time, one tar file that includes all the following: all source and header files a readme file, which must include:o a preamble (program author(s), purpose, list of source/header/data files)o exact compilation command(s)o launching and operating instructionsGrading Marking breakdown:ComponentMarksdata types15supporting stack functions50instrumentation functions25stack output to file10 Assignment grade: Your grade will be computed based on the completeness of your implementation, plus bonus marks, minus deductions. Deductions: 100 marks if:o any files are missing from your submission, or if they are corrupt or in the wrong format 50 marks if:o the code does not compile using gcc in the Ubuntu Linux shell environmento unauthorized changes have been made to the header and/or source files provided for youo code cannot be tested because it doesnt run 25 marks if:o your submission consists of anything other than exactly one tar fileo your program is not broken down into multiple reusable, modular functionso your code is not correctly separated into header and source fileso your program uses global variables (unless otherwise explicitly permitted)o the readme file is missing or incomplete 10 marks for missing comments or other bad style (non-standard indentation, improper identifier names, etc) Bonus marks: Up to 5 extra marks are available for fun and creative additional features
Programming
[Solved] SOLVED:COMP 2401 Assignment #3
$25
File Name: SOLVED:COMP_2401__Assignment_#3.zip
File Size: 292.02 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.