-
A lexical analyzer
analyzer.pyis used for classifing the task into n categories and a list of scores is generated for each categories. -
To run the analyzer use
python3 analyzer.py. The main function analyze's syntax is as follows.analyze(directory=False, directory_name=None, output=False, output_file_name=None, file_name=None)Arguements:
directory (boolean): If set toTrueit analyzes all the programs in the directory,directory_nameargument must be givendirectory_name (string): Ifdirectoryis set toTrue, the name of the directory must be given.output (boolean): Set toTrueif output is needed,Falseotherwise.output_file_name (string): File name of output if output flag is set to True.file_name (string): Ifdirectoryis set toFalse, then a file name must be given. -
The programs outputs two lists of scores. One is a task specific score for different resources such as (memory, compute, network, etc..), and the other is a resource specific score comparing all programs (if multiple exits).
The utilsation of each resources in a VM running a task is obtained and is used in the schediling of task. A live state of resources are used for scheduling.
- A bash script
utilization.shis used to get the current resource usage of the VM running the program. Avm_idis assigned to each VM and in this case is the Machine's username obtained usingwhoamicommand.topcommand is used to get the CPU and memory usage.bwm-ngcommand is used to get the network usage.
- The output of the previous script is parsed with
util_extractor.py.
read_vm_characteristicsis exposed by this file and is used to parse the output from the previous script, given the output file name as input.
This task allocationn requires a live table of resource usage(or available free resource) of each VMs to which tasks needed to be scheduled. It also requires each task to be analyzed using the lexical analyzer as mentioned before
vm_allocator.py is used for task allocation to VMs. This program exposes the following main functions
insert_new_vm: Given a utilization file as the one generated byutilization.shit extracts the usage characteristics and inserts it into thevm_tableusingupdate_sorted_listsupdate_sorted_lists: This is used internally by the above function to sort the VMs based on each characteristic and is inserted.update_vm: This is used to update the usage characteristic of an existing VM in the VM table.independent_Task2Vm: This function schedules a single task and needs two inputs one is a list oftask_scoresfor the task, and thetask_nameto be put in queue.dependent_Task2Vm: This functions allocates VMs for multiple tasks. It requires two inputs.task_scoreslist for all the tasks and asorted_task_nameswhich is 2d list that is generated by the function given below.create_sorted_task_names: This function given a 2d list of task scores for multiple tasks, genrates a sorted list of task names to be used independent_Task2Vm.
- Sample Programs have been given under
/programsdirectory. - Three files
util0.txt,util1.txt,util2.txthave been generated.
-
python3
-
pip3
In case of ubuntu
sudo apt-get install python3-pip -
tokenizer module
pip3 install tokenizer
Analyzer
python3 analyzer.py
Util File Parser
python3 util_extractor.py
Allocator
python3 vm_allocator.py
Shreyas Seshadri - 16IT135
Akhil N kashyap - 16IT104
GS Dhanush - 16IT219