/*
* File: name_HW2.c
* Author: Shravan kumar
*
* Created on 28 September, 2018, 1:17 AM
*/
#include <signal.h>
#include <unistd.h>
#include "tlpi_hdr.h"
#include <setjmp.h>
/* declare variable of type jmp_buf */
jmp_buf resume_here;
void intHandler()
{
printf("This is an interrupt handler\n");
longjmp(resume_here,1);
// Long jmp is used here so that the control goes to setjmp after ctrl +c is entered
exit(EXIT_SUCCESS);
}
void func1()
{
printf("Working!\n");
while(1)
{/*Infinite loop made by mistake*/
printf("Looping...\n");
sleep(1);
}
}
void func2 ()
{
printf("Resumed!\n");
return; // return statement returns to main function
exit(EXIT_SUCCESS);
}
int main (int argc, char*argv[])
{
switch (setjmp(resume_here)) // switch case with set jmp is
used
{
case 0:
signal(SIGINT,intHandler);
func1();
case 1:
func2();
}
printf("You did a good job!");
}
Output:
Need help with this please! Linux related! Name: Score:/60 Submit the assignment at the blackboard. The...
Pleas help I need to create and array to add to my code something like this for (i = 0; i < NUM_THREADS; ++i) { thr_data[i].tid = i; if ((rc = pthread_create(&thr[i], NULL, thr_func, &thr_data[i]))) { fprintf(stderr, "error: pthread_create, rc: %d\n", rc); return EXIT_FAILURE; ::::::::: CODE ::::::::::::: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> int sharedVar = 0; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /* thread handler */ void *threadHandler(void *vargp) { int i = 0; pthread_mutex_lock(&mutex); ...
Design and implement a C version of the color match program. As a starting point, use the file HW2-1-shell.c. The program should employ a reasonable algorithm that compares all pairings of colors in the palette exactly once. A color should not be compared to itself. Nor should two colors be compared to each other more than once. Your C program should print out the total component color difference for the closest pair using the print string provided in the shell...
I need help solving this assignment, you are given a full piece of code that does not run correctly. Some of the bugs can be found at compile time, while others are found at run time. Access the UserMenu.cpp code file (in the zip file in Start Here) and use debugging practices and the debugger in Visual Studio to find each bug. Fix the bug and write a comment in the code giving a description of how you found the...
I need help with the following code... Instructions: This lab builds on the skills from Lab 2c, in which you read data values from a file and kept a count of the number of invalid values. In this lab, your program will be using the same code to read each data entry from the file, but you will also save each value in an array named allMags after each is read in. When all values in the file have been...
C LANGUAGE. PLEASE INCLUDE COMMENTS :) >>>>TheCafe V2.c<<<< #include <stdio.h> int main() { int fries; // A flag denoting whether they want fries or not. char bacon; // A character for storing their bacon preference. double cost = 0.0; // The total cost of their meal, initialized to start at 0.0 int choice; // A variable new to version 2, choice is an int that will store the // user's menu choice. It will also serve as our loop control...
Need help for C program. Thx #include <stdio.h> #include <string.h> #include <ctype.h> // READ BEFORE YOU START: // This homework is built on homework 06. The given program is an updated version of hw06 solution. It begins by displaying a menu to the user // with the add() function from the last homework, as well as some new options: add an actor/actress to a movie, display a list of movies for // an actor/actress, delete all movies, display all movies,...
I am needing help with the last part of this code. I have gotten each part working correctly accept getting the menu options to work by input and getting to the right section. your help is appreciated. I am to the menu in the code is the display menu and need an loop to interact until they want to exit menu. The edit options only needs an output of "feature is not yet implemented." Due to length I did not...
Please help modify my C program to be able to answer these questions, it seems the spacing and some functions arn't working as planeed. Please do NOT copy and paste other work as the answer, I need my source code to be modified. Source code: #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main(void) { char title[50]; char col1[50]; char col2[50]; int point[50]; char names[50][50]; printf("Enter a title for the data:\n"); fgets (title, 50, stdin); printf("You entered: %s\n", title);...
Please I need help in C language, I am trying to modify the code per the below instructions, but I am getting errors. Can't fgure it out. The attempted code modification and data file is privided below, after the instructions. Thank you. Instructions: 1. First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts....