Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The remarks are just instructions. Please do it in C. Thanks Write a program which generates arbitrary process trees from a given input file. Your

image text in transcribed

The remarks are just instructions. Please do it in C. Thanks

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 sleep ) 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 must decide how to represent the nodes and their names in your input file so that they can be uniquely mapped to the tree under consideration. For instance, how to distinguish between DFS vs. BFS nodes? Scheme 1: Example of a process tree. Under one scenario, as an example, a process tree may be described as follows: A 2 B C B 1 D Remark 1: 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 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 2 helps understand how to represent the remaining tree when stored in the memory of an internal process tree node. You should not pass part of the original file as file", but pass only the amount of information required stored as linked list or some other structure. Remark 3: Write a function that reads the tree from file, constructs its representation in memory and returns a pointer to the root: read tree file (const char filename). Also write a function that runs the tree starting from root and prints its elements: print tree (struct tree_node root) Remark 4: You must build the process tree, not just a tree data structure. However, for every process tree node you are building you must pass on the information of the remaining sub-tree recursively. Also, you must print out the tree after creation using the process tree. For this, you will need some form of IPC for interaction across processes (go up or down the tree). You may choose to print in a recursive fashion Question: What is the order of appearance of start and termination messages from processes and why? 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 sleep ) 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 must decide how to represent the nodes and their names in your input file so that they can be uniquely mapped to the tree under consideration. For instance, how to distinguish between DFS vs. BFS nodes? Scheme 1: Example of a process tree. Under one scenario, as an example, a process tree may be described as follows: A 2 B C B 1 D Remark 1: 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 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 2 helps understand how to represent the remaining tree when stored in the memory of an internal process tree node. You should not pass part of the original file as file", but pass only the amount of information required stored as linked list or some other structure. Remark 3: Write a function that reads the tree from file, constructs its representation in memory and returns a pointer to the root: read tree file (const char filename). Also write a function that runs the tree starting from root and prints its elements: print tree (struct tree_node root) Remark 4: You must build the process tree, not just a tree data structure. However, for every process tree node you are building you must pass on the information of the remaining sub-tree recursively. Also, you must print out the tree after creation using the process tree. For this, you will need some form of IPC for interaction across processes (go up or down the tree). You may choose to print in a recursive fashion Question: What is the order of appearance of start and termination messages from 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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Describe workplace bullying.

Answered: 1 week ago

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago