Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
Transcribed Image Text:The program shown in Figure 4.22 uses the Pthreads API. What would be the output from the program at LINE C
and LINE P?
#include <pthread.h>
#include <stdio.h>
int value = 0;
void *runner(void *param); /* the thread */
int main(int argc, char *argv [])
pid_t pid;
pthread_t tid;
pthread attr_t attr;
pid = fork();
if (pid == 0) { /* child process */
pthread_attr.init(&attr);
pthread_create (&tid,&attr,runner,NULL);
pthread_join(tid,NULL);
printf("CHILD: value = %d",value); /* LINE C */
else if (pid > 0) { /* parent process */
wait (NULL);
printf("PARENT: value = %d",value); /* LINE P */
}
void *runner(void *param) {
value - 5;
pthread_exit(0);
Figure 4.22 C program for Exercise 4.19.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- PP 13.3 Create a new version of the LinkedStack class that makes use of a dummy record at the head of the list. PP 13.4 Create a simple graphical application that will allow a user to perform push, pop, and peek operations on a stack, and display the resulting stack (using toString) in a text area.arrow_forwardComplete the following code. The goal is to implement the producer-consumer problem. You are expected to extend the provided C code to synchronize the thread operations consumer() and producer() such that an underflow and overflow of the queue is prevented. You are not allowed to change the code for implementing the queue operations, that is the code between lines 25 and 126 as shown in the Figure below. You must complete the missing parts between lines 226-261 as shown in the screenshot.arrow_forwardSolution question number 2arrow_forward
- 10/** 2 IN3 &in mm 4 */ 5 6 public class StackTrace 7 { 80 9 10 11 12 13 14 150 16 17 18 190 20 21 22 23 24 25 260 27 28 29 300 31 32 33 34 35 3456N This program demonstrates the stack trace that is produced when an exception is thrown. 36 public static void main(String[] args) { System.out.println("Calling myMethod..."); System.out.println("Method main is done."); } /** */ } /** myMethod(); public static void myMethod() { System.out.println("Calling produceError..."); System.out.println("myMethod is done."); */ MyMethod 37 } 38 produceError(); produceError public static void produceError() { String str = "abc"; // The following statement will cause an error. System.out.println(str.charAt(3)); System.out.println("peoduceError is done."); Problems @Javadoc Declaration Console Xarrow_forwardusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LibraryManagment { class Program {// private static int userInput;// need varaible to capture user input = int public static string Title { get; private set; } public static bool IsChecked { get; private set; } //Implement a menu system that allows users to add books, check out books, //and check in books using the console. Use Console.ReadLine() ///to capture user input and Console.WriteLine() for output. static void Main(string[] args) {// provides a cosole interaction for a user while (IsChecked) { Console.WriteLine("\nMenu\n" + "1)Add book\n" + "2)Check Out Book\n" + "3)Check In Book\n" + "4)Exit\n"); Console.Write("Choose your...arrow_forwardOCaml Code: The goal of this project is to understand and build an interpreter for a small, OCaml-like, stackbased bytecode language. Make sure that the code compiles correctly and provide the code with the screenshot of the output. Make sure to have the following methods below: -Push integers, strings, and names on the stack -Push booleans -Pushing an error literal or unit literal will push :error: or :unit:onto the stack, respectively -Command pop removes the top value from the stack -The command add refers to integer addition. Since this is a binary operator, it consumes the toptwo values in the stack, calculates the sum and pushes the result back to the stack - Command sub refers to integer subtraction -Command mul refers to integer multiplication -Command div refers to integer division -Command rem refers to the remainder of integer division -Command neg is to calculate the negation of an integer -Command swap interchanges the top two elements in the stack, meaning that the...arrow_forward
- Write a program that takes as input an arithmetic expression. The program outputs whether the expression contains matching grouping symbols (brackets and parentheses). For example, the arithmetic expressions {25 + (3 – 6) * 8} and 7 + 8 * 2 contains matching grouping symbols. However, the expression 5 + {(13 + 7) / 8 - 2 * 9 does not contain matching grouping symbols. You must use a stack and/or queue. USE THE FOLLOWING DATA FILE //Header file: stackADT.h #ifndef H_StackADT#define H_StackADT template <class Type>class stackADT{public:virtual void initializeStack() = 0;//Method to initialize the stack to an empty state.//Postcondition: Stack is emptyvirtual bool isEmptyStack() const = 0;//Function to determine whether the stack is empty.//Postcondition: Returns true if the stack is empty,// otherwise returns false.virtual bool isFullStack() const = 0;//Function to determine whether the stack is full.//Postcondition: Returns true if the stack is full,// otherwise returns...arrow_forwardComputer Science For the basic ADT Queue operations, list all cases when a QueueException will be thrown. Each item listed should be no more than 10 words and ONLY in the form "exception name : cause of exception". Remember to use correct terminology or the answer will not be acceptedarrow_forwardIn C++,arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education