/* sends a message to the processor with the specified actor, tagged with the recipients id */ void send_msg(int *sendbuf, int count, MPI_Datatype type, int actor_dest, MPI_Comm comm) { int tag = actor_dest; int dest; dest = find_actor(actor_dest); MPI_Bsend(sendbuf, count, type, dest, tag, comm); }
/* called by the processpool, sends the data to actorcontrol to start a new actor */ void start_actor(int actor_num, int actor_type, int initial, int tot_landcells, int infected) { int command[6]; int dest; dest = find_actor(actor_num); command[0] = ACTORSTART; command[1] = actor_type; command[2] = actor_num; command[3] = initial; command[4] = tot_landcells; command[5] = infected; MPI_Bsend(command, 6, MPI_INT, dest, 0, frame_comm); }
void send_func(caStack* stack) { #if 0 // actorList disabled const char* actorSymbol = circa_string_input(stack, 0); caValue* msg = circa_input(stack, 1); if (stack->world == NULL) { circa_output_error(stack, "Stack was not created with World"); return; } ListData* actor = find_actor(stack->world, actorName); if (actor == NULL) { std::string msg = "Actor not found: "; msg += actorName; circa_output_error(stack, msg.c_str()); return; } actor_send_message(actor, msg); #endif }
// used for hw07 // The helper2 function is used to determine how much information is needed, and which function to send that information to. // It uses pointers that are returned from these functions to produce the correct ouput. // There is no implementation needed here, but you should study this function and know how it works. // It is always helpful to understand how the code works before implementing new features. // Do not change anything in this function or the test cases will fail. void helper2(char c) { int index = 0; // used to print an index int genre = -1; char* movie_name; char* actor_name; movie_name = (char*)malloc(5000 * sizeof(char*)); actor_name = (char*)malloc(5000 * sizeof(char*)); if (c == 'b') // add an actor/actress to a movie { printf("Enter the actor/actress name:\n"); flush(); fgets(actor_name, line_size, stdin); printf("Enter the movie they were they in:\n"); fgets(movie_name, line_size, stdin); int result = add_actor(movie_name, actor_name); if (result == 0) { printf("That movie is not in your list, please add that movie first.\n\n"); } else if (result == 1) { printf("Actor added.\n\n"); } else if (result == -1) { printf("That actor is already listed for that movie.\n\n"); } } if (c == 'c') // display a list of movies for an actor/actress { printf("Enter the actor/actress name:\n"); flush(); fgets(actor_name, line_size, stdin); struct movie* temp = find_actor(actor_name); if (temp != NULL) { printf("That actor/actress is in:\n"); print_helper(temp); // ADDED TO PREVENT MEMORY LEAKS struct movie* temp2; while (temp != NULL) { temp2 = temp; temp = temp->next; free(temp2); } } else printf("That actor is not in any movies in your list.\n\n", index); } if (c == 'd') // delete all movies { delete_all(list); printf("All movies deleted.\n"); } if (c == 'e') // display all movies print_helper(print_all(list)); if (c == 'f') // display a movie by index { printf("Enter an index to print:\n"); while (index < 1) { scanf("%d", &index); if (index < 1) printf("Enter an index greater than 0:\n"); } struct movie* temp = print_by_index(index); if (temp != NULL) { struct actor* ptr = temp->actors; printf("Movie at index %d:\n", index); printf("Movie: %s", temp->name); printf("Rating: %d\n", temp->rating); printf("Genre: %s\n", gen[temp->type]); printf("Actor/Actress: "); if (ptr == NULL) { printf("no actor/actress listed.\n\n"); } else { printf("\n"); while (ptr != NULL) { printf("%s", ptr->name); ptr = ptr->next; } printf("\n"); } } else printf("There is no movie at index %d.\n\n", index); } if (c == 'g') // display a list of movies by genre { printf("Select a genre to display\n0. action\n1. comedy\n2. thriller\n"); while (genre < 0 || genre > 2) { scanf("%d", &genre); // enter an integer onl if (genre < 0 || genre > 2) printf("Select a valid option:\n"); } struct movie* temp = print_by_genre(genre); if (temp != NULL) { printf("%s movies:\n", gen[genre]); print_helper(temp); // ADDED TO PREVENT MEMORY LEAKS struct movie* temp2; while (temp != NULL) { temp2 = temp; temp = temp->next; free(temp2); } } else printf("There are no %s movies in the list.\n\n", gen[genre]); } free(actor_name); // ADDED TO PREVENT MEMORY LEAKS free(movie_name); // ADDED TO PREVENT MEMORY LEAKS }