Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: Arbitrary process tree generation (20 points) You are asked to write a program which generates arbitrary process trees from a given input file.

image text in transcribed

image text in transcribed

image text in transcribed

Problem 2: Arbitrary process tree generation (20 points) You are asked to write a program which generates arbitrary process trees from a given input file. Your program is based on a recursive function which will be called for every tree node. If the tree node has children, the function will create them and will wait until they are terminated. If the tree node does not have children, the function will call sleep0 with a predefined argument. The input file contains the description of a tree, node after node, starting from the root. For every node, you must specify its name, the number of children and the names of the children. You are responsible for figuring out how to represent the nodes and their rn they can be uniquely mapped to the tree under consideration. For instance, how to distinguish between DFS vs. BFS nodes? ames in your input file so that Under one scenario, the process tree of scheme 1 may be described as follows: A 2 B C B1 D D 0 There may be better and more efficient ways to build our input file though. Select the representation that is convenient and optimal for your program. Remark 1: Another very important feature of your process tree is that now, based on your experience with Problem 0, you must ensure you do not generate more processes than what your system can handle. So, please justify in your report, what the size of the process tree you selected is and why Remark 2: Every tree node is defined by the struct: tree_node, which contains the number of children (children_no), and the name of the node and pointer to the area where contiguous children no structs are placed, one for every child node Remark 3: You are asked to write a function that reads the tree from the file, constructs its representation in memory and returns a pointer to the root: read_ tree_file (const char *filename). You are also asked to write a function that runs the tree starting from root and prints its elements on the screen: print_tree (struct tree_node *root) Question: What is the order of appearance of the start and termination messages from the processes and why? Problem 2: Arbitrary process tree generation (20 points) You are asked to write a program which generates arbitrary process trees from a given input file. Your program is based on a recursive function which will be called for every tree node. If the tree node has children, the function will create them and will wait until they are terminated. If the tree node does not have children, the function will call sleep0 with a predefined argument. The input file contains the description of a tree, node after node, starting from the root. For every node, you must specify its name, the number of children and the names of the children. You are responsible for figuring out how to represent the nodes and their rn they can be uniquely mapped to the tree under consideration. For instance, how to distinguish between DFS vs. BFS nodes? ames in your input file so that Under one scenario, the process tree of scheme 1 may be described as follows: A 2 B C B1 D D 0 There may be better and more efficient ways to build our input file though. Select the representation that is convenient and optimal for your program. Remark 1: Another very important feature of your process tree is that now, based on your experience with Problem 0, you must ensure you do not generate more processes than what your system can handle. So, please justify in your report, what the size of the process tree you selected is and why Remark 2: Every tree node is defined by the struct: tree_node, which contains the number of children (children_no), and the name of the node and pointer to the area where contiguous children no structs are placed, one for every child node Remark 3: You are asked to write a function that reads the tree from the file, constructs its representation in memory and returns a pointer to the root: read_ tree_file (const char *filename). You are also asked to write a function that runs the tree starting from root and prints its elements on the screen: print_tree (struct tree_node *root) Question: What is the order of appearance of the start and termination messages from the processes and why

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Solve each triangle. a = 9, b = 7, c = 10

Answered: 1 week ago