You are a highly renowned research university professor. I will give you students' submissions for the below assignment. I have also provided the grading rubric which you have to use to give points to the students' submission. Evaluate each submission independently, following all instructions. Provide rubric-based evidence to validate the grade assigned to each submission. I will give you students code submission to the assignment.  The deduction you apply should be against the correct rubric item only. If you are deducting points for a rubric, then along with showing evidence of deduction you should mention how it should be fixed. Make sure you remember these instructions for each submission and incase you lose context of this then you have to ask me to provide it again but in no way can you hallucinate in your responses


###Grading Rubric:###



###balancer_init (3 pts)###

Full Marks (3 pts): Properly initialized the batch size and mutex.
Competent (1.5 pts): Batch size was not set, or mutex was not created, or did not create the object properly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###balancer_destroy (3 pts)###

Full Marks (3 pts): Shuts down the load balancer.
Competent (1.5 pts): Does not correctly manage the load balancer or did not destruct the object properly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###balancer_add_job (I) (6 pts)###

Full Marks (6 pts): Jobs are inserted in the batch correctly while being protected by a mutex.
Competent (3 pts): Jobs are inserted but not correctly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###balancer_add_job (II) (5 pts)###

Full Marks (5 pts): When enough jobs have been added, creates a batch and sends it to the instance host. The same instance host must be used for all batches.
Competent (2.5 pts): Does not create the batch, or the batch is not equal to the batch size.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###host_init (4 pts)###

Full Marks (4 pts): Initializes any local variables, including mutexes.
Competent (2 pts): Incorrect initialization of variables, or did not create the object properly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###host_destroy (3 pts)###

Full Marks (3 pts): Checks for remaining batches and completes them. Any mutexes created in host_init are destroyed.
Competent (1.5 pts): Does not check for remaining batches or did not destruct the object properly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.
###host_request_instance (I) (6 pts)###

Full Marks (6 pts): Each batch has a separate thread.
Competent (3 pts): Incorrect instance spawn for every thread.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###host_request_instance (II) (5 pts)###

Full Marks (5 pts): Each job is processed and returned to the user correctly.
Competent (2.5 pts): Data is not being processed and returned to the user correctly.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.

###balancer_destroy (II) (5 pts)###

Full Marks (5 pts): Uses an instance to complete any leftover jobs.
Competent (2.5 pts): Does not process all leftover jobs.
No Marks (0 pts): Did not attempt or the attempt was very incomplete.


This will be the default User.c file, if I dont provide a User.c file with the students submission then by default you will the below code for User.c. 

/**
 * Program to simulate multiple users simultaneously requesting work (a "job")
 * to be carried by a load balancing server and returned to the user. Job is to
 * compute the square of a number.
 * 
 * @author Khan, Acuna
 * @version 1.2
 */
#define _POSIX_C_SOURCE 199506L

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "LoadBalancer.h"

//forward declarations for internal (private) functions.
void* simulate_user_request(void* user_id);

//variable to store load balancer object
balancer* lb;

/**
 * Entry point to simulation.
 * 
 * @return Zero.
 */
int main() {
	int number_of_requests = 10;
    int batch_size = 5;
	printf("Please input number of requests (users): ");
	//scanf("%d", &number_of_requests);
	printf("Please input batch size: ");
	//scanf("%d", &batch_size);

	pthread_t threads[number_of_requests];

    lb = balancer_create(batch_size);

    //create number_of_requests number of users that want to square a number.
    for (int i = 0; i < number_of_requests; i++) {
        printf("creating: %d\n", i);
        pthread_create(&threads[i], NULL, &simulate_user_request, (void*)i);
    }

    nanosleep((struct timespec[]){{2, 0}}, NULL); //wait two seconds

    balancer_destroy(&lb);

    //wait for all users to finish before program exit.
    for (int i = 0; i < number_of_requests; i++)
        pthread_join(threads[i], NULL);   
    
    return 0;
}

/**
 * Simulates a user requesting work to be done a server. Expected to be run in a
 * thread.
 * 
 * @param user_id
 * @return 
 */
void* simulate_user_request(void* user_id) {
    int data = rand() % 100;
    int* result = (int*)malloc(sizeof(int));
    *result = -1;
    
    //make the thread wait to simulate differences in when user requests occur.
    int ms = (rand() % 100) * 1000;
    nanosleep((struct timespec[]){{0, ms*1000000}}, NULL);
    
    printf("User #%d: Wants to process data=%d and store it at %p.\n", (int)user_id, data, result);
    
    //make request to balance to complete job and wait for it's completion.
    balancer_add_job(lb, (int)user_id, data, result);
    while(*result == -1);  //busy waiting, bad but simple
    
    printf("User #%d: Received result from data=%d as result=%d.\n", (int)user_id, data, *result);
    
    free(result);
    
    pthread_exit(NULL);
}