2. Write a C program for each of the following system calls (one per call) which uses the call in a normal manner. Make sure that your program compiles and executes without error. Show the output from each of the programs. Please check for, and report, any errors. Terminate execution on error (do not continue running if a call fails). a) sbrk b) fork c) sched_getaffinity The last one is a bit tricky. The main page has a lot of useful information on the parameters. The cpu_set_t is an opaque type: You are not meant to manipulate it directly. There are macros in sched.h which will set/clear/test members of the set. The man page for CPU_SET(3) describes these. Of particular interest is CPU_ISSET. The number of cores can be found with sysconf(_SC_NJPROCESSORS_ONLN). This is the number of hyperthreads, not the number of raw cores. It is also the size of the CPU mask. #include #include int main() { } long ncores = sysconf(_SC_NPROCESSORS_ONLN); printf("%d cores found\n", ncores); The CPU mask is a list of values which are either 1 or 0 depending on whether the given process is allowed to run on that logical core. You can iterate over possible values: for (i = 0; i
2. Write a C program for each of the following system calls (one per call) which uses the call in a normal manner. Make sure that your program compiles and executes without error. Show the output from each of the programs. Please check for, and report, any errors. Terminate execution on error (do not continue running if a call fails). a) sbrk b) fork c) sched_getaffinity The last one is a bit tricky. The main page has a lot of useful information on the parameters. The cpu_set_t is an opaque type: You are not meant to manipulate it directly. There are macros in sched.h which will set/clear/test members of the set. The man page for CPU_SET(3) describes these. Of particular interest is CPU_ISSET. The number of cores can be found with sysconf(_SC_NJPROCESSORS_ONLN). This is the number of hyperthreads, not the number of raw cores. It is also the size of the CPU mask. #include #include int main() { } long ncores = sysconf(_SC_NPROCESSORS_ONLN); printf("%d cores found\n", ncores); The CPU mask is a list of values which are either 1 or 0 depending on whether the given process is allowed to run on that logical core. You can iterate over possible values: for (i = 0; i
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
need help for parts A and C. i use mac terminal. When i tried, i got warnings and errors. Please guide me step by step along with the answer!
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education