Implement a version of the standard I/O fgets function, called tfgets, that times out and returns NULL if it does not receive an input line on standard input within 5 seconds. Your function should be implemented in a package called tfgets-proc.c using processes, signals, and nonlocal jumps. It should not use the Linux alarm function. Test your solution using the driver program in Figure 12.47.
________________________________________________________code/conc/tfgets-main.c
________________________________________________________code/conc/tfgets-main.c
Figure 12.47 Driver program for Problems 12.31-12.33.
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
Computer Systems: Program... -Access
Additional Engineering Textbook Solutions
C Programming Language
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with C++: Early Objects
Starting Out With Visual Basic (8th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
- This is a MASM Project Assembly Code for x86 Processors ! The code below is supposed to copy whatever's in the source variable into the target variable. However, there is a single error, which will cause it to work correctly if fixed. What is it? .datasource WORD 10 DUP("AO")target WORD 10 DUP(?).codemov esi, OFFSET sourceadd esi, 18mov edi, OFFSET targetadd edi, 18mov ecx, LENGTHOF targetstdrepe movsw Group of answer choices: A: 18 should not be added to the ESI and EDI registers B: ECX should be set to the length of the source, not the target C: The direction flag should be cleared with CLD, not set with STD D: The REPE prefix should be replaced with REParrow_forwardModify the program below to implement exclusive-or (XOR) in Python. AsPython does not natively implement XOR, you will need to implement this by creating an expression using a combination of and, or, and not. Determine what this expression is, and put it in the code below (where “fill in your code here” is written).The starter code below includes the True/True and True/False cases. You should also include the False/True and False/False cases. As a reminder, XOR is only True if exactly one of the inputs is True. Other ways ofthinking about this is that it is True only if one input or the other input is True, but not both. Yet another way of thinking about this is that the result is only True when the inputs are different from each other. SAMPLE STARTER CODE:a = Trueb = Trueresult = # fill in your code hereprint("True XOR True is " + str(result))a = Trueb = Falseresult = # fill in your code hereprint("True XOR False is " + str(result))# Continue for the False/True and False/False…arrow_forwardWrite a program, sonar.c, compiled with GCC on the RPi 3b/3b+, that performs the following stepsusing the provided sysfs_gpio files:a. Include the sysfs_gpio.h fileb. Initializes the TRIGGER pin to be an output by calling gpioOutput()c. Initializes the ECHO pin to be an input by calling gpioInput()d. Sets Trig signal high (1) and then low (0)e. Zero a count variablef. Enter a while loop that waits until the Echo signal goes highThere is no code in the while loopg. The program exits the first looph. Enter another while loop that waits until the Echo signal goes lowThe while loop contains code that increments the count variablei. The program exits the second loopj. The count value is now proportional to the distance traveledk. Print the raw count valuel. Convert the value to a distance (cm) by empirical means(the desk is about 4 feet or 122 cm in length) sysfs_gpio.c: #include <stdio.h>//-----------------------------------------------------------------------------//…arrow_forward
- Write a program, sonar.c, compiled with GCC on the RPi 3b/3b+, that performs the following steps using the provided sysfs_gpio files: a. Include the sysfs_gpio.h file b. Initializes the TRIGGER pin to be an output by calling gpioOutput() c. Initializes the ECHO pin to be an input by calling gpioInput() d. Sets Trig signal high (1) and then low (0) e. Zero a count variable f. Enter a while loop that waits until the Echo signal goes high There is no code in the while loop g. The program exits the first loop h. Enter another while loop that waits until the Echo signal goes low The while loop contains code that increments the count variable i. The program exits the second loop j. The count value is now proportional to the distance traveled k. Print the raw count value l. Convert the value to a distance (cm) by empirical means (the desk is about 4 feet or 122 cm in length) sysfs_gpio.c: #include…arrow_forwardImplement the FindText() function, which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The function returns the number of instances a word or phrase is found in the string. In the PrintMenu() function, prompt the user for a word or phrase to be found and then call FindText() in the PrintMenu() function. Before the prompt, call cin.ignore() to allow the user to input a new string.Ex: Enter a word or phrase to be found: more "more" instances: 5arrow_forwardThe following Python code returns this error, and I have no idea how to fix it. Any and all help would be appreciated Traceback (most recent call last): File "D:\Grand Canyon University\CST_580\Topic 4\project 6a.py", line 40, in <module> agent.move() File "D:\Grand Canyon University\CST_580\Topic 4\project 6a.py", line 13, in move new_location = self.current_location + direction ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~TypeError: unsupported operand type(s) for +: 'int' and 'str' <start of Python code> import random class Agent: def __init__(self, start_location, destination_location): self.current_location = start_location self.destination_location = destination_location def move(self): # Randomly choose a direction to move in direction = random.choice(['up', 'down', 'left', 'right']) # Move in the chosen direction new_location = self.current_location + direction # Calculate the distance to the…arrow_forward
- Write a program named Lab2b_Act2a.py that will take two observed 3D positions at two points in time, and then will calculate the 3D position at a third point in time. Let’s consider only times between the two observed times. You should output the x, y, and z values for that position on separate lines. Begin by identifying the variables you will use, the names for those variables, and the computations that should occur for those variables. Then, write a program that will output the 3D position of the interpolated point on 3 separate lines. For this initial program, use the following data values:●At time 12 seconds, observed position was (2, 3, 7) meters●At time 85 seconds, observed position was (25, -5, 11) meters●You want to find the position at time 45 seconds. Now, copy Lab2b_Act2a.py from above into a new program named Lab2b_Act2b.py. Modify your program in the following ways:i.When printing the position, follow the output by a line of dashes (“-------------------”).ii.Instead of…arrow_forwardIn this assignment you are required to implement the following using convolution . a) apply sharpen filter with different kernels, compare the results? You need to write program/ codearrow_forwardAnother question, I suppose to draw a snowflake using this function, but everytime I get to the "whole" part when I put part 1,2,3 together, python tells me that I'm getting Syntax errors. def snowflake(): part1 = kochize(5) part2 = rotate(2*(pi/3))(kochize(5)) part3 = rotate((-2*(pi/3))(kochize(5)) whole = connect_ends((part1, part2), part3) return whole I don't understand why am I getting syntax errors with line5 of this function.arrow_forward
- Write a program that converts an ASCII text string from memory into all lowercase and stores the output to memory. The input string can contain uppercase and lowercase letters as well as spaces, punctuation (period, comma, question mark, exclamation point), and decimal digits. The input string will be null-terminated (that is, end with a 0 byte) and the output string is also to be null-terminated. (Observe: a 0 byte is different than the ASCII code for decimal digit 0 , which is 0x30.) Example: Convert the string "IN 2023, faLL stARTs on September 23." to "in 2023, fall starts on september 23.".arrow_forwardThe dirname utility treats its argument as a pathname and writes to standard output the path prefix—that is, everything up to but not including the last component: $ dirname a/b/c/d a/b/c If you give dirname a simple filename (no / characters) as an argument, dir-name writes a . to standard output: $ dirname simple . Implement dirname as a bash function. Make sure it behaves sensibly when given such arguments as /.arrow_forwardImplement a function called tautology? that takes as input a fully parenthesized formula and returns true if it is a tautology and false otherwise. As was the case in the previous lab, the formula will contain at least one set of parentheses for each operator, but may contain more. The best strategy for doing is to use an insight called Quine's method. It is based on the observation that if a formula, such as (p or (not p)), is a tautology, the result of substituting p with true is a tautology and the result of substituting p with false is also a tautology. This implies a computational strategy: to evaluate whether a formula F is a tautology1. Collect all of the propositional variables.2. Substitute every occurrence of the first variable with #t and every occurrence ofthe same variable with #f3. Make two recursive calls to Tautology? “And” the results.4. When all possible substitutions have been made, i.e., the formula contains onlytruth values, evaluate the formula and return the…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr