ECS150 Project 2 solution

$29.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

You will be working with a partner for this project, you specify your partner in your readme file. This specification is subject to change at anytime for additional clarification. For this project, you and a partner will be implementing a virtual machine threading API in either C or C++. Your virtual machine will be tested on the CSIF machines. You must submit your source files, readme and Makefile in a zip or tar.gz file to smartsite prior to the deadline.

You will be provided a machine abstraction upon which you will be building the thread scheduler. The virtual machine will load the “applications” from shared objects that implement the VMMain function. The virtual machine will need to support multiple user space preemptive threads. The virtual machine mutex API provides synchronization mechanism and file access is provided through the file API.

Threads have three priority levels low, medium, and high. Threads are created in the dead state and have and have state transitions as shown below.

A makefile has been provided that compiles the virtual machine as long as you provide your code as VirtualMachine.c or VirtualMachine.cpp. It will create the virtual machine call vm. The applications can be built by making the apps with make apps. New apps can be built by adding a C or C++ file in the apps directory and adding $(BINDIR)/filename.so to the Makefile apps line dependencies.

A working example of the vm and apps can be found in /home/cjnitta/ecs150. The vm syntax is vm [option] appname [appargs]. The possible option for vm is -t; -t specifies the tick time in millisecond. By default this is set to 100ms, for debugging purposes you can increase these values to slow the running of the vm. When specifying the application name the ./ should be prepended otherwise vm may fail to load the shared object file.

The machine layer is implemented using a cooperative process that communicates using the System V message queues. As such during your development your program may crash prior to the closing of the message queues. In order to determine the message queue
Ready Running
Waiting
Dead1
2
3
45
6
1. I/O, acquire mutex or timeout 2. Scheduler selects process 3. Process quantum up 4. Process terminates 5. Process activated 6. Process blocks
4
4
ECS150 SQ16 April 18, 2016
Project 2 2 of 40
id, you can use the ipcs command from the shell. You can remove the message queue with a call to ipcrm. You can read more about the System V IPC commands at: http://man7.org/linux/man-pages/man1/ipcs.1.html http://man7.org/linux/man-pages/man1/ipcrm.1.html

The function specifications for both the virtual machine and machine are provided in the subsequent pages.

You should avoid using existing source code as a primer that is currently available on the Internet. You must specify in your readme file any sources of code that you or your partner have viewed to help you complete this project. All class projects will be submitted to MOSS to determine if pairs of students have excessively collaborated with other pairs. Excessive collaboration, or failure to list external code sources will result in the matter being transferred to Student Judicial Affairs.

ECS150 SQ16 April 18, 2016
Project 2 3 of 40
Name VMStart – Start the virtual machine. Synopsys #include “VirtualMachine.h”
TVMStatus VMStart(int tickms, int argc, char *argv[]); Description VMStart() starts the virtual machine by loading the module specified by argv[0]. The argc and argv are passed directly into the VMMain() function that exists in the loaded module. The time in milliseconds of the virtual machine tick is specified by the tickms parameter. Return Value Upon successful loading and running of the VMMain() function, VMStart() will return VM_STATUS_SUCCESS after VMMain() returns. If the module fails to load, or the module does not contain a VMMain() function, VM_STATUS_FAILURE is returned.
ECS150 SQ16 April 18, 2016
Project 2 4 of 40
Name VMLoadModule – Loads the module and returns a reference to VMMain function. Synopsys #include “VirtualMachine.h” typedef void (*TVMMainEntry)(int, char*[]);
TVMMainEntry VMLoadModule(const char *module); Description VMLoadModule() loads the shared object module (or application) specified by the module filename. Once the module has been loaded a reference to VMMain function obtained. The source for VMLoadModule is provided in VirtualMachineUtils.c Return Value Upon successful loading of the module specified by module filename, a reference to the VMMain function is returned, upon failure NULL is returned.