In Section 3.6.6, we examined the following code as a candidate for the use of conditional data transfer:
long cread (long *xp) {
return (xp ? xp : 0);
}
We showed a trial implementation using a conditional move instruction but argued that it was not valid, since it could attempt to read from a null address.
Write a C function cread_alt that has the same behavior as cread, except that it can be compiled to use conditional data transfer. When compiled, the generated code should use a conditional move instruction rather than one of the jump instructions.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Experiencing MIS
Database Concepts (8th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- In C, using this interface: void setSortThreads(int count);void sortThreaded(char** array, unsigned int count); How can you modify the following quicksort program in order to use multithreading, with the goal of performing faster than qsort for large data sets? Use basic parallelization and limit the number of threads to the amount held by the global variable maximumThreads, specified by the user (when they call setSortThreads in the main function). If possible it would be helpful to test the code on a big text file, like maybe the dictionary. I'll include a sample main function at the end that I have been using. You would need your own text file to test it on, though. #include <stdlib.h>#include <string.h>#include <pthread.h>#define SORT_THRESHOLD 40typedef struct _sortParams {char** array;int left;int right;} SortParams;static int maximumThreads; /* maximum # of threads to be used *//* This is an implementation of insert sort, which although it is *//*…arrow_forwardIn C, using this interface: void setSortThreads(int count);void sortThreaded(char** array, unsigned int count); How can you modify the following quicksort program in order to use multithreading, with the goal of performing faster than qsort for large data sets? Use basic parallelization and limit the number of threads to the amount held by the global variable maximumThreads, specified by the user (when they call setSortThreads in the main function). If possible it would be helpful to test the code on a big text file, like maybe the dictionary. I'll include a sample main function at the end that I have been using. You would need your own text file to test it on. #include <stdlib.h> #include <stdio.h>#include <string.h>#include <pthread.h> #include <time.h>#define SORT_THRESHOLD 40typedef struct _sortParams {char** array;int left;int right;} SortParams;static int maximumThreads; /* maximum # of threads to be used *//* This is an implementation of…arrow_forwardDo execution paths 3 and 4 encompass the first three conditions for a deadlock to occur?arrow_forward
- A common implementation of sequential files on disk has each block point to its successor, which may be any block on the disk. This method requires a constant amount of time to write a block (as the file is originally written), to read the first block in the file, and to read the ith block, once you have read the 1 - 1” block. Reading the lth block therefore requires time proportional to 1. Show how by adding just one additional pointer per node, you can keep all the other properties, but allow the lth block to be read in time proportional to log I. [Hint: heaps have implicit pointers from node I to what other nodes?] Explain what the algorithm for reading the th block has in common with an algorithm for raising a number to the ith power in time proportional to log 1.arrow_forwardNow consider the Verilog version of this same simple multicycle implementation: http://aggregate.org/CPE380/multiv.html (Links to an external site.) . Which of the following statements about how that works is false? Group of answer choices The bench module instantiates a processor called PE, and generates the clock input signal to it Symbolic names for things like word size and the implementation of each control signal are given using `define The main memory is a reg array defined in a separate memory module, which is instantiated within the processor module The ALU is specified as using a ripple-carry adder rather than carry lookahead, etc. The control logic is implemented by a case statement that performs the appropriate action(s) for the current STATEarrow_forwardSomeone tries to fix the stack based buffer overflow problem as follows, is it secure now? why? Are there any other issues within the function's implementation below? Explain your reasoning. int bof(char *str, int size) { char *buffer = (char *) malloc(size); strcpy(buffer, str); return 1; }arrow_forward
- 1 All of the following data values are examples of unsigned datatypes in HLA EXCEPT a uns32 b uns16 c int8 d uns8 2 How many bits of stack memory are used when passing an int32 variable by-reference to a function? a 32 b 8 c 16 d 64 3 How many bits of stack memory are used when passing an int16 variable by-value to a function? a 32 b 8 c 16 d 64arrow_forwardWhat is the smallest unsigned value we must pass to the following function to trigger a stack overflow (assuming a stack size of 64 bytes and that we are compiling and running as the only task on an x86-64 system)? Give your answer in decimal. unsigned long rec(unsigned long x){ if(!x) return 17; return rec(x >> 1) << 1; }arrow_forwardSomeone tries to fix the stack based buffer overflow problem as follows, is it secure now? why? Are there any other issues within the function's implementation below? int bof(char *str, int size) { char *buffer = (char *) malloc(size); strcpy(buffer, str); return 1; }arrow_forward
- Develop a C/C++ program that accepts the name of a memory trace file as a command line argument. Use the data to simulate a set associative cache using LRU replacement. Additional command line arguments will be needed to identify the details of the simulated cache. The arguments should appear in the following order: the memory trace input file X, where 2X == the number of direct-mapped sets Y, where 2Y == the number of blocks per set Z, where 2Z == the number of cached words per block Your program (say it's a compiled C program) could be run like this: ./cache data.tra 3 2 4 This would simulate an 8 set associative LRU cache with 4 blocks per set, where each block caches 16 addresses. NOTE… the reason I've chosen to use exponents for arguments is to ensure we have powers of 2 for everything. Trace File The trace file is line based with each line containing a memory address requested, in hex. Please note this data is real, so the addresses are larger than 32-bits. In…arrow_forwardImplement priority round robin scheduling in C and calculate the average turnaround time, wait time and response time It must use task.h, list.h and cpu.h. Text files = rr-schedule.txt T1, 0, 40, 50T2, 1, 40, 50T3, 2, 40, 50T4, 3, 40, 50T5, 4, 40, 50T6, 5, 40, 50 pri-schedule.txt T1, 0, 1, 50T2, 1, 1, 50T3, 2, 1, 50T4, 3, 1, 50T5, 4, 1, 50T6, 5, 1, 50arrow_forwardYou are required to demonstrate the running time difference between a linked listand a binary search tree while searching the data. Read the following instructionsand then implement a C++ program that can address the above requirement.1- choose byself a .csv file containing the data named Dataset.csv The dataset file contains a record of 100000 sales records of astore. By using the text file reading method in C++, read the data of the file in alinked list and a binary search tree. (In a single program) After reading the data validate the data reading by implementing a print() method. Take a sales id as an input from the user and search that ID in the linked listand binary search tree. Display the running time difference of both data structures during the searchoperation.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education