What We Talk About When We Talk About Unit TestingKevlin Henney
Presented at ACCU (23rd April 2015)
These days unit testing is considered sexy for programmers. Who'd have thought it? But there is a lot more to effective programmer testing than the fashionable donning of a unit-testing framework: writing Good Unit Tests (GUTs) involves (a lot) more than knowledge of assertion syntax.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What styles of test partitioning are common, and yet scale poorly, are uncohesive and are ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and scalable to large codebases? How do we choose between scenario-based and property-based test cases?
From typing the test to testing the typeWim Godden
PHP unit testing + new PHPUnit patch for type testing functionality
Seems bullet points are not working and some of the slides are not so clear because of Slideshare conversion.
Presentation given at phpBenelux meeting August 25, 2010
What We Talk About When We Talk About Unit TestingKevlin Henney
Presented at ACCU (23rd April 2015)
These days unit testing is considered sexy for programmers. Who'd have thought it? But there is a lot more to effective programmer testing than the fashionable donning of a unit-testing framework: writing Good Unit Tests (GUTs) involves (a lot) more than knowledge of assertion syntax.
Testing represents a form of communication and, as such, it offers multiple levels and forms of feedback, not just basic defect detection. Effective unit testing requires an understanding of what forms of feedback and communication are offered by tests, and what styles encourage or discourage such qualities.
What styles of test partitioning are common, and yet scale poorly, are uncohesive and are ineffective at properly expressing the behaviour of a class or component? What styles, tricks and tips can be used to make tests more specification-like and scalable to large codebases? How do we choose between scenario-based and property-based test cases?
From typing the test to testing the typeWim Godden
PHP unit testing + new PHPUnit patch for type testing functionality
Seems bullet points are not working and some of the slides are not so clear because of Slideshare conversion.
Presentation given at phpBenelux meeting August 25, 2010
C-Program Custom Library, Header File, and Implementation FilesI .pdfherminaherman
C-Program: Custom Library, Header File, and Implementation Files
I have this main.c file:
#include
#include
#include \"stats.h\"
int readGrades(char fileName[], float grades[]);
//Include this function prototype
void WelcomeToTheProgram();
int main()
{
///Declare Variables
char fileName[30];
float grades[1000]; //to store grades
int i, ArrayCount[10] = {0}; //to store histogram counts
/* Rewrite this line */
int num_grades; //for # of grades in file
///Call Intro Comment
WelcomeToTheProgram();
///Enter Filename
printf(\"\ \ \ Enter the data filename: \");
scanf(\"%s\", &fileName);
//Get # of grades in file
num_grades = readGrades(fileName, grades); //get # of grades in file
///Print Results
printf(\"There are %d grades read\ \", num_grades);
printf(\"Mean = %f\ \", mean(grades, num_grades));
printf(\"Variance = %f \ \", variance(grades, num_grades));
printf(\"Maximum = %f \ \", maximum(grades, num_grades));
printf(\"Minumum = %f \ \", minimum(grades, num_grades));
//Call histogram
histogram(grades, ArrayCount, num_grades);
//Print the histogram
printf(\"Grade Histogram\ \");
for (i = 0; i < 10; i++)
{
if (i != 9)
{
printf(\"\ %d %% - %d %%: %d \", i * 10, ((i + 1) * 10) - 1, ArrayCount[i]);
}
else
{
printf(\"\ 90 %% - 100 %%: %d\ \", ArrayCount[i]);
}
}
return 0;
}
///Reads all grades from the file to array
int readGrades(char fileName[], float grades[])
{
FILE *fpin = fopen(fileName, \"r\");
int num_scores = 0;
float value;
if (fpin == NULL)
{
printf(\"Cannot open the file\ \");
exit(0);
}
while ((fscanf(fpin, \"%f\", &value)) != EOF)
{
grades[num_scores] = value;
num_scores++;
}
return num_scores;
}
void WelcomeToTheProgram()
{
printf(\"***Welcome to the Program Which Involves a Custom Library***\");
printf(\"\ The program finds the minimum value, maximum value, mean,\");
printf(\"variance, and a histogram of the grades of data by calling\");
printf(\"implementation files min(), max(), mean(), variance(), and histogram().\ \");
}
But, the only thing that prints is
Enter the data file name: grades.txt
There are 400 grades read.
Then the program just stops, it does not print the min, max, mean, variance, or histogram. Any
ideas? Am I using the custom library wrong, the implementation files (for min, max, mean,
variance, and histogram) all check out with no warnings or errors.
Here is stats.h:
#ifndef STATS_H
#define STATS_H
float minimum(float *grades[], int Size); // NOTE: You need to complete the prototypes
float maximum(float *grades[], int Size);
float mean(float *grades[], int Size);
float variance(float *grades[], int Size);
void histogram(float *grades[], int *ArrayCount, int Size);
#endif // STATS_H
And here is the grades file:
Solution
//stats.h
#ifndef STATS_H
#define STATS_H
float minimum(float grades[], int Size); // NOTE: You need to complete the prototypes
float maximum(float grades[], int Size);
float mean(float grades[], int Size);
float variance(float grades[], int Size);
void histogram(float grades[], int ArrayCount[], int S.
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docxshandicollingwood
E2 – Fundamentals, Functions & Arrays
Please refer to announcements for details about this exam. Make sure you fill the information below to avoid not being graded properly;
Last Name
Hanrahan
First Name
Kane
Student ID #
U84918862
Here is the grading matrix where the TA will leave feedback. If you scored 100%, you will most likely not see any feedback
Question
# points
Feedback
Max
Scored
1
Tracing
3
2
Testing
2
3
Refactoring
2
4
Debugging
3
Interlude – How to Trace Recursive Programs
To help you fill the trace table in question #1, we start with an example of a small recursive program & provide you with the trace table we expect you to draw.
Example Program to Trace
This program implements a power function recursively. We do not have local variables in either function, thus making the information in each activation record a bit shorter.
#include
#include
int pwr(int x, int y){
if( y == 0 ) return 1;
if( y == 1 ) return x;
return x * pwr(x, y-1);
}
int main(){
printf("%d to power %d is %d\n", 5, 3, pwr(5,3));
return EXIT_SUCCESS;
}
Example Trace Table
Please note the following about the table below;
We only write down the contents of the stack when it is changed, i.e. when we enter a function or assign a new value to a variable in the current activation record.
When we write the contents of the stack, we write the contents of the whole stack, including previous activation records.
Each activation record is identified by a bold line specifying the name of the function & the parameters passed to it when it was invoked.
It is followed by a bullet list with one item per parameter or local variable.
New activation records are added at the end of the contents of the previous stack
Line #
What happens?
Stack is
10
Entering main function
main’s activation record
No local vars / parameters
11
Invoking function pwr as part of executing the printf
Stack is the same, no need to repeat it
4
Entering pwr function with arguments 5 & 3
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
5
Testing if y is 0
false
6
Testing if y is 1
false
7
Invoking pwr(5,2) as part of return statement
4
Entering pwr function with arguments 5 & 2
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
5
Testing if y is 0
false
6
Testing if y is 1
false
7
Invoking pwr(5,1)
4
Entering pwr function with arguments 5 & 1
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
pwr(5,1) activation record
x is 5
y is 1
5
Testing if y is 0
false
6
Testing if y is 1
true
6
Return value x which is 5
7
Back from invocation of pwr(5,1) with result 5.
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
7
Return the result * x
= 5 * 5
= .
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docxjacksnathalie
E2 – Fundamentals, Functions & Arrays
Please refer to announcements for details about this exam. Make sure you fill the information below to avoid not being graded properly;
Last Name
First Name
Student ID #
Here is the grading matrix where the TA will leave feedback. If you scored 100%, you will most likely not see any feedback (
Question
# points
Feedback
Max
Scored
1
Tracing
3
2
Testing
2
3
Refactoring
2
4
Debugging
3
Interlude – How to Trace Recursive Programs
To help you fill the trace table in question #1, we start with an example of a small recursive program & provide you with the trace table we expect you to draw.
Example Program to Trace
This program implements a power function recursively. We do not have local variables in either function, thus making the information in each activation record a bit shorter.
1 #include <stdio.h>
2 #include <stdlib.h>
3 int pwr(int x, int y){
4
if( y == 0 )
return 1;
5
if( y == 1 )
return x;
6
return x * pwr(x, y-1);
7 }
8 int main(){
9
printf("%d to power %d is %d\n", 5, 3, pwr(5,3));
10
return EXIT_SUCCESS;
11 }
Example Trace Table
Please note the following about the table below;
· We only write down the contents of the stack when it is changed, i.e. when we enter a function or assign a new value to a variable in the current activation record.
· When we write the contents of the stack, we write the contents of the whole stack, including previous activation records.
· Each activation record is identified by a bold line specifying the name of the function & the parameters passed to it when it was invoked.
· It is followed by a bullet list with one item per parameter or local variable.
· New activation records are added at the end of the contents of the previous stack
Line #
What happens?
Stack is
10
Entering main function
main’s activation record
· No local vars / parameters
11
Invoking function pwr as part of executing the printf
Stack is the same, no need to repeat it
4
Entering pwr function with arguments 5 & 3
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
5
Testing if y is 0 ( false
6
Testing if y is 1 ( false
7
Invoking pwr(5,2) as part of return statement
4
Entering pwr function with arguments 5 & 2
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
pwr(5,2) activation record
· x is 5
· y is 2
5
Testing if y is 0 ( false
6
Testing if y is 1 ( false
7
Invoking pwr(5,1)
4
Entering pwr function with arguments 5 & 1
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
pwr(5,2) activation record
· x is 5
· y is 2
pwr(5,1) activation record
· x is 5
· y is 1
5
Testing if y is 0 ( false
6
Testing if y is 1 ( true
6
Return value x which is 5
7
Back from invocation of pwr(5,1) with result 5.
main’s activation record
· No local vars / parameters
pwr(5,3) activation r ...
assign4-2/.DS_Store
assign4-2/assign4_part2/mymem.h
#include <stddef.h>
typedef enum strategies_enum
{
NotSet = 0,
Best = 1,
Worst = 2,
First = 3,
Next = 4
} strategies;
char *strategy_name(strategies strategy);
strategies strategyFromString(char * strategy);
void initmem(strategies strategy, size_t sz);
void *mymalloc(size_t requested);
void myfree(void* block);
int mem_holes();
int mem_allocated();
int mem_free();
int mem_total();
int mem_largest_free();
int mem_small_free(int size);
char mem_is_alloc(void *ptr);
void* mem_pool();
void print_memory();
void print_memory_status();
void try_mymem(int argc, char **argv);
assign4-2/assign4_part2/memorytests.c
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <unistd.h>
#include "mymem.h"
#include "testrunner.h"
/* performs a randomized test:
totalSize == the total size of the memory pool, as passed to initmem2
totalSize must be less than 10,000 * minBlockSize
fillRatio == when the allocated memory is >= fillRatio * totalSize, a block is freed;
otherwise, a new block is allocated.
If a block cannot be allocated, this is tallied and a random block is freed immediately thereafter in the next iteration
minBlockSize, maxBlockSize == size for allocated blocks is picked uniformly at random between these two numbers, inclusive
*/
void do_randomized_test(int strategyToUse, int totalSize, float fillRatio, int minBlockSize, int maxBlockSize, int iterations)
{
void * pointers[10000];
int storedPointers = 0;
int strategy;
int lbound = 1;
int ubound = 4;
int smallBlockSize = maxBlockSize/10;
if (strategyToUse>0)
lbound=ubound=strategyToUse;
FILE *log;
log = fopen("tests.log","a");
if(log == NULL) {
perror("Can't append to log file.\n");
return;
}
fprintf(log,"Running randomized tests: pool size == %d, fill ratio == %f, block size is from %d to %d, %d iterations\n",totalSize,fillRatio,minBlockSize,maxBlockSize,iterations);
fclose(log);
for (strategy = lbound; strategy <= ubound; strategy++)
{
double sum_largest_free = 0;
double sum_hole_size = 0;
double sum_allocated = 0;
int failed_allocations = 0;
double sum_small = 0;
struct timespec execstart, execend;
int force_free = 0;
int i;
storedPointers = 0;
initmem(strategy,totalSize);
clock_gettime(CLOCK_REALTIME, &execstart);
for (i = 0; i < iterations; i++)
{
if ( (i % 10000)==0 )
srand ( time(NULL) );
if (!force_free && (mem_free() > (totalSize * (1-fillRatio))))
{
int newBlockSize = (rand()%(maxBlockSize-minBlockSize+1))+minBlockSize;
/* allocate */
void * pointer = mymalloc(newBlockSize);
if (pointer != NULL)
pointers[storedPointers++] = pointer;
else
{
failed_allocations++;
force_free = 1;
}
}
else
{
int chosen;
void * pointe ...
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
-I am unable to accept emailed exams or late exams. No exception.docxgertrudebellgrove
-I am unable to accept emailed exams or late exams. No exceptions.
-For technical issues you would need to go through tech support.
-Turn in work early to avoid technical issues. Technical issues are not a valid reason for failing to submit work.
-Make sure to research the exam drop box and where to find it a week or more ahead.
-Make sure to read all announcements and most importantly around exam times.
-The Professor has 2-3 days to grade the exam and once graded you need to check your grade book. I do not release exam grades via email.
-For any directions only contact your Professor, DO NOT use “all student” email to email other students because this only confuses them and points will be deducted as well as violations of the course policies
--Most exams you are given a FULL WEEK to complete. I also indicate day one of the course what the exam will cover and include. Do not email me the last minute to turn in work or ask any questions. I may not be available the hour before an exam so it is important to plan ahead.
- Review the sample exam to gain an A. Follow the length, and structured, apply APA format and go in depth. It is not too rough but points are deducted for failing to following the samples.
-Please do BOTH (1) copy and paste your work into the dropbox comment are or area provided, PLUS (2) attach the file. PLEASE DO BOTH. For attachments it must be in word. If it is any other format, or I am unable to open the file (such as word perfect) a 0 (zero) will be granted and no re-submissions will be allowed)
-See your course due dates for any dates as well as announcements. These are set and well planned week 1.
-Do not use work you previously submitted this term or a past one, do not work with anyone and do not plagiarize. This will result in a 0/F and I want you to gain an A!
-1 page each question, APA format.
-Keep an eye on your gradebook for grades. I am unable to respond to “confirm” if it is submitted or not, you can do so with tech support if needed.
NOTE +++IF YOUR TEXT DOES NOT HAVE END OF CHAPTER QUESTIONS, YOU MAY SUMMARIZE EACH CHAPTER IN DEPTH, THAT MEANS ALL CHAPTERS 7,8,9,10,11,12
EXAM worth 25 points.
READ ALL OF THE DIRECTIONS OR POINTS WILL BE DEDUCTED.
Grades will be final and I will not discuss the grade or
change a grade under any circumstances.
Work alone.
IMPORTANT NOTES:
Feel free to attach and/or copy and paste the work into the provided drop box.
No emailed papers will count.
IF YOUR CLASS HAS A DROPBOX THAT IS THE MAIN AREA TO SUBMIT THE EXAM
If I cannot open it I will not GRADE IT.
I will not accept ANY late work for exams.
FOLLOW THE DATES IN THE SYLLABUS ONLY!
YOU HAVE till the date listed on the syllabus to email it back to me. Good luck!
USE APA FORMAT
Please email me with any questions. DO NOT WORK WITH ANYONE! Put time into it and go IN DEPTH!
Please apply Primary sources, journals, articles, etc.
The Midterm is essay/short answer. Use the readings, the discussion .
-delineate characteristics, prevalence of exceptionality-evalua.docxgertrudebellgrove
-delineate characteristics, prevalence of exceptionality
-evaluate causes and concerns of each exceptionality
-critique and analyses component of the IEP
-identify and analyze instructional assessment and strategies to the individual with the exceptional needs
Follow the rubs. 4 DOUBLE SPACE with running head
.
More Related Content
Similar to YOU SHOULD NOT MODIFY ANYTHING IN THIS FILE .docx
C-Program Custom Library, Header File, and Implementation FilesI .pdfherminaherman
C-Program: Custom Library, Header File, and Implementation Files
I have this main.c file:
#include
#include
#include \"stats.h\"
int readGrades(char fileName[], float grades[]);
//Include this function prototype
void WelcomeToTheProgram();
int main()
{
///Declare Variables
char fileName[30];
float grades[1000]; //to store grades
int i, ArrayCount[10] = {0}; //to store histogram counts
/* Rewrite this line */
int num_grades; //for # of grades in file
///Call Intro Comment
WelcomeToTheProgram();
///Enter Filename
printf(\"\ \ \ Enter the data filename: \");
scanf(\"%s\", &fileName);
//Get # of grades in file
num_grades = readGrades(fileName, grades); //get # of grades in file
///Print Results
printf(\"There are %d grades read\ \", num_grades);
printf(\"Mean = %f\ \", mean(grades, num_grades));
printf(\"Variance = %f \ \", variance(grades, num_grades));
printf(\"Maximum = %f \ \", maximum(grades, num_grades));
printf(\"Minumum = %f \ \", minimum(grades, num_grades));
//Call histogram
histogram(grades, ArrayCount, num_grades);
//Print the histogram
printf(\"Grade Histogram\ \");
for (i = 0; i < 10; i++)
{
if (i != 9)
{
printf(\"\ %d %% - %d %%: %d \", i * 10, ((i + 1) * 10) - 1, ArrayCount[i]);
}
else
{
printf(\"\ 90 %% - 100 %%: %d\ \", ArrayCount[i]);
}
}
return 0;
}
///Reads all grades from the file to array
int readGrades(char fileName[], float grades[])
{
FILE *fpin = fopen(fileName, \"r\");
int num_scores = 0;
float value;
if (fpin == NULL)
{
printf(\"Cannot open the file\ \");
exit(0);
}
while ((fscanf(fpin, \"%f\", &value)) != EOF)
{
grades[num_scores] = value;
num_scores++;
}
return num_scores;
}
void WelcomeToTheProgram()
{
printf(\"***Welcome to the Program Which Involves a Custom Library***\");
printf(\"\ The program finds the minimum value, maximum value, mean,\");
printf(\"variance, and a histogram of the grades of data by calling\");
printf(\"implementation files min(), max(), mean(), variance(), and histogram().\ \");
}
But, the only thing that prints is
Enter the data file name: grades.txt
There are 400 grades read.
Then the program just stops, it does not print the min, max, mean, variance, or histogram. Any
ideas? Am I using the custom library wrong, the implementation files (for min, max, mean,
variance, and histogram) all check out with no warnings or errors.
Here is stats.h:
#ifndef STATS_H
#define STATS_H
float minimum(float *grades[], int Size); // NOTE: You need to complete the prototypes
float maximum(float *grades[], int Size);
float mean(float *grades[], int Size);
float variance(float *grades[], int Size);
void histogram(float *grades[], int *ArrayCount, int Size);
#endif // STATS_H
And here is the grades file:
Solution
//stats.h
#ifndef STATS_H
#define STATS_H
float minimum(float grades[], int Size); // NOTE: You need to complete the prototypes
float maximum(float grades[], int Size);
float mean(float grades[], int Size);
float variance(float grades[], int Size);
void histogram(float grades[], int ArrayCount[], int S.
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docxshandicollingwood
E2 – Fundamentals, Functions & Arrays
Please refer to announcements for details about this exam. Make sure you fill the information below to avoid not being graded properly;
Last Name
Hanrahan
First Name
Kane
Student ID #
U84918862
Here is the grading matrix where the TA will leave feedback. If you scored 100%, you will most likely not see any feedback
Question
# points
Feedback
Max
Scored
1
Tracing
3
2
Testing
2
3
Refactoring
2
4
Debugging
3
Interlude – How to Trace Recursive Programs
To help you fill the trace table in question #1, we start with an example of a small recursive program & provide you with the trace table we expect you to draw.
Example Program to Trace
This program implements a power function recursively. We do not have local variables in either function, thus making the information in each activation record a bit shorter.
#include
#include
int pwr(int x, int y){
if( y == 0 ) return 1;
if( y == 1 ) return x;
return x * pwr(x, y-1);
}
int main(){
printf("%d to power %d is %d\n", 5, 3, pwr(5,3));
return EXIT_SUCCESS;
}
Example Trace Table
Please note the following about the table below;
We only write down the contents of the stack when it is changed, i.e. when we enter a function or assign a new value to a variable in the current activation record.
When we write the contents of the stack, we write the contents of the whole stack, including previous activation records.
Each activation record is identified by a bold line specifying the name of the function & the parameters passed to it when it was invoked.
It is followed by a bullet list with one item per parameter or local variable.
New activation records are added at the end of the contents of the previous stack
Line #
What happens?
Stack is
10
Entering main function
main’s activation record
No local vars / parameters
11
Invoking function pwr as part of executing the printf
Stack is the same, no need to repeat it
4
Entering pwr function with arguments 5 & 3
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
5
Testing if y is 0
false
6
Testing if y is 1
false
7
Invoking pwr(5,2) as part of return statement
4
Entering pwr function with arguments 5 & 2
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
5
Testing if y is 0
false
6
Testing if y is 1
false
7
Invoking pwr(5,1)
4
Entering pwr function with arguments 5 & 1
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
pwr(5,1) activation record
x is 5
y is 1
5
Testing if y is 0
false
6
Testing if y is 1
true
6
Return value x which is 5
7
Back from invocation of pwr(5,1) with result 5.
main’s activation record
No local vars / parameters
pwr(5,3) activation record
x is 5
y is 3
pwr(5,2) activation record
x is 5
y is 2
7
Return the result * x
= 5 * 5
= .
E2 – Fundamentals, Functions & ArraysPlease refer to announcemen.docxjacksnathalie
E2 – Fundamentals, Functions & Arrays
Please refer to announcements for details about this exam. Make sure you fill the information below to avoid not being graded properly;
Last Name
First Name
Student ID #
Here is the grading matrix where the TA will leave feedback. If you scored 100%, you will most likely not see any feedback (
Question
# points
Feedback
Max
Scored
1
Tracing
3
2
Testing
2
3
Refactoring
2
4
Debugging
3
Interlude – How to Trace Recursive Programs
To help you fill the trace table in question #1, we start with an example of a small recursive program & provide you with the trace table we expect you to draw.
Example Program to Trace
This program implements a power function recursively. We do not have local variables in either function, thus making the information in each activation record a bit shorter.
1 #include <stdio.h>
2 #include <stdlib.h>
3 int pwr(int x, int y){
4
if( y == 0 )
return 1;
5
if( y == 1 )
return x;
6
return x * pwr(x, y-1);
7 }
8 int main(){
9
printf("%d to power %d is %d\n", 5, 3, pwr(5,3));
10
return EXIT_SUCCESS;
11 }
Example Trace Table
Please note the following about the table below;
· We only write down the contents of the stack when it is changed, i.e. when we enter a function or assign a new value to a variable in the current activation record.
· When we write the contents of the stack, we write the contents of the whole stack, including previous activation records.
· Each activation record is identified by a bold line specifying the name of the function & the parameters passed to it when it was invoked.
· It is followed by a bullet list with one item per parameter or local variable.
· New activation records are added at the end of the contents of the previous stack
Line #
What happens?
Stack is
10
Entering main function
main’s activation record
· No local vars / parameters
11
Invoking function pwr as part of executing the printf
Stack is the same, no need to repeat it
4
Entering pwr function with arguments 5 & 3
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
5
Testing if y is 0 ( false
6
Testing if y is 1 ( false
7
Invoking pwr(5,2) as part of return statement
4
Entering pwr function with arguments 5 & 2
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
pwr(5,2) activation record
· x is 5
· y is 2
5
Testing if y is 0 ( false
6
Testing if y is 1 ( false
7
Invoking pwr(5,1)
4
Entering pwr function with arguments 5 & 1
main’s activation record
· No local vars / parameters
pwr(5,3) activation record
· x is 5
· y is 3
pwr(5,2) activation record
· x is 5
· y is 2
pwr(5,1) activation record
· x is 5
· y is 1
5
Testing if y is 0 ( false
6
Testing if y is 1 ( true
6
Return value x which is 5
7
Back from invocation of pwr(5,1) with result 5.
main’s activation record
· No local vars / parameters
pwr(5,3) activation r ...
assign4-2/.DS_Store
assign4-2/assign4_part2/mymem.h
#include <stddef.h>
typedef enum strategies_enum
{
NotSet = 0,
Best = 1,
Worst = 2,
First = 3,
Next = 4
} strategies;
char *strategy_name(strategies strategy);
strategies strategyFromString(char * strategy);
void initmem(strategies strategy, size_t sz);
void *mymalloc(size_t requested);
void myfree(void* block);
int mem_holes();
int mem_allocated();
int mem_free();
int mem_total();
int mem_largest_free();
int mem_small_free(int size);
char mem_is_alloc(void *ptr);
void* mem_pool();
void print_memory();
void print_memory_status();
void try_mymem(int argc, char **argv);
assign4-2/assign4_part2/memorytests.c
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <unistd.h>
#include "mymem.h"
#include "testrunner.h"
/* performs a randomized test:
totalSize == the total size of the memory pool, as passed to initmem2
totalSize must be less than 10,000 * minBlockSize
fillRatio == when the allocated memory is >= fillRatio * totalSize, a block is freed;
otherwise, a new block is allocated.
If a block cannot be allocated, this is tallied and a random block is freed immediately thereafter in the next iteration
minBlockSize, maxBlockSize == size for allocated blocks is picked uniformly at random between these two numbers, inclusive
*/
void do_randomized_test(int strategyToUse, int totalSize, float fillRatio, int minBlockSize, int maxBlockSize, int iterations)
{
void * pointers[10000];
int storedPointers = 0;
int strategy;
int lbound = 1;
int ubound = 4;
int smallBlockSize = maxBlockSize/10;
if (strategyToUse>0)
lbound=ubound=strategyToUse;
FILE *log;
log = fopen("tests.log","a");
if(log == NULL) {
perror("Can't append to log file.\n");
return;
}
fprintf(log,"Running randomized tests: pool size == %d, fill ratio == %f, block size is from %d to %d, %d iterations\n",totalSize,fillRatio,minBlockSize,maxBlockSize,iterations);
fclose(log);
for (strategy = lbound; strategy <= ubound; strategy++)
{
double sum_largest_free = 0;
double sum_hole_size = 0;
double sum_allocated = 0;
int failed_allocations = 0;
double sum_small = 0;
struct timespec execstart, execend;
int force_free = 0;
int i;
storedPointers = 0;
initmem(strategy,totalSize);
clock_gettime(CLOCK_REALTIME, &execstart);
for (i = 0; i < iterations; i++)
{
if ( (i % 10000)==0 )
srand ( time(NULL) );
if (!force_free && (mem_free() > (totalSize * (1-fillRatio))))
{
int newBlockSize = (rand()%(maxBlockSize-minBlockSize+1))+minBlockSize;
/* allocate */
void * pointer = mymalloc(newBlockSize);
if (pointer != NULL)
pointers[storedPointers++] = pointer;
else
{
failed_allocations++;
force_free = 1;
}
}
else
{
int chosen;
void * pointe ...
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
-I am unable to accept emailed exams or late exams. No exception.docxgertrudebellgrove
-I am unable to accept emailed exams or late exams. No exceptions.
-For technical issues you would need to go through tech support.
-Turn in work early to avoid technical issues. Technical issues are not a valid reason for failing to submit work.
-Make sure to research the exam drop box and where to find it a week or more ahead.
-Make sure to read all announcements and most importantly around exam times.
-The Professor has 2-3 days to grade the exam and once graded you need to check your grade book. I do not release exam grades via email.
-For any directions only contact your Professor, DO NOT use “all student” email to email other students because this only confuses them and points will be deducted as well as violations of the course policies
--Most exams you are given a FULL WEEK to complete. I also indicate day one of the course what the exam will cover and include. Do not email me the last minute to turn in work or ask any questions. I may not be available the hour before an exam so it is important to plan ahead.
- Review the sample exam to gain an A. Follow the length, and structured, apply APA format and go in depth. It is not too rough but points are deducted for failing to following the samples.
-Please do BOTH (1) copy and paste your work into the dropbox comment are or area provided, PLUS (2) attach the file. PLEASE DO BOTH. For attachments it must be in word. If it is any other format, or I am unable to open the file (such as word perfect) a 0 (zero) will be granted and no re-submissions will be allowed)
-See your course due dates for any dates as well as announcements. These are set and well planned week 1.
-Do not use work you previously submitted this term or a past one, do not work with anyone and do not plagiarize. This will result in a 0/F and I want you to gain an A!
-1 page each question, APA format.
-Keep an eye on your gradebook for grades. I am unable to respond to “confirm” if it is submitted or not, you can do so with tech support if needed.
NOTE +++IF YOUR TEXT DOES NOT HAVE END OF CHAPTER QUESTIONS, YOU MAY SUMMARIZE EACH CHAPTER IN DEPTH, THAT MEANS ALL CHAPTERS 7,8,9,10,11,12
EXAM worth 25 points.
READ ALL OF THE DIRECTIONS OR POINTS WILL BE DEDUCTED.
Grades will be final and I will not discuss the grade or
change a grade under any circumstances.
Work alone.
IMPORTANT NOTES:
Feel free to attach and/or copy and paste the work into the provided drop box.
No emailed papers will count.
IF YOUR CLASS HAS A DROPBOX THAT IS THE MAIN AREA TO SUBMIT THE EXAM
If I cannot open it I will not GRADE IT.
I will not accept ANY late work for exams.
FOLLOW THE DATES IN THE SYLLABUS ONLY!
YOU HAVE till the date listed on the syllabus to email it back to me. Good luck!
USE APA FORMAT
Please email me with any questions. DO NOT WORK WITH ANYONE! Put time into it and go IN DEPTH!
Please apply Primary sources, journals, articles, etc.
The Midterm is essay/short answer. Use the readings, the discussion .
-delineate characteristics, prevalence of exceptionality-evalua.docxgertrudebellgrove
-delineate characteristics, prevalence of exceptionality
-evaluate causes and concerns of each exceptionality
-critique and analyses component of the IEP
-identify and analyze instructional assessment and strategies to the individual with the exceptional needs
Follow the rubs. 4 DOUBLE SPACE with running head
.
-1st play name is READY STEADY YETI GO-2nd play name is INTO .docxgertrudebellgrove
-1st play name is "READY STEADY YETI GO"
-2nd play name is "INTO THE WOODS "
REVIEW PAPER GUIDELINES (3 pages,
Essay format) Introduction
Plot
What happens?
E.g., “Mother Courage follows the misadventures of Courage and her children over a ten year period during the 100 Years War...”
How does it happen?
E.g., “The play is built in a series of episodes, alternating personal struggles against a backdrop of the larger social/political struggles.”
What does it mean?
A one-two sentence that captures the essence of the action. In the case of Epic Theatre, this statement is primarily about the intended “lesson” of the play. E.g., “MC is about how capitalism inevitably leads to the corruption then destruction of society—from nations to families.”
Rhythm
Flow of the plots?
Character
Main character Description
E.g., “Courage is a middle-aged mother of three who will stop at nothing to exploit the financial opportunities she encounters. Her role in the play is ‘survivor.’ Her character is the ‘anti-mom’—a woman who sees her children (and other human beings) as a collection of debits and credits.”
Second Character Description
Thought—what are the ideas in the play
e.g., Mother Courage looks at the intersection of war and commerce and how one feeds off the other, to the destruction of land, civilization, and families. The ideas arise out of the work of Karl Marx. Summarize--
Historical (Where and When) Philosophical (What & Why)
Diction--
Summarize the language the playwright uses. How do the characters speak?
E.g., prose, poetry, cliché, long speeches, short, etc.?
7 of 8
Music—
is more than song, but the SOUND of the play. Describe the aural environment created and executed in the production.
Spectacle
—describe the visual environment of light and scenery created for the production, and their execution and relevance (e.g., it could look great but mean nothing, or it could look terrible but somehow it works!)
Conclusion
A paragraph about your particular feelings about the play—did it engage you? Were you changed, even a little? Goethe asked three questions—What was it trying to do? How well was it done? Was it worth doing? Answer these questions.
.
-6th-Edition-Template-without-Abstract.dotWhat are Heuristics .docxgertrudebellgrove
-6th-Edition-Template-without-Abstract.dot
What are Heuristics and can it lead to bias?
Why is Maslow's Hierarchy a basic psychological stable? (Watch the video for better understanding and cite it)
How does FEAR keep you alive? (See emotions and feelings video)
Please write 300 or more words and APA to address the above concepts for week four.
.
- write one 5-7 page paper about All forms of Euthanasia are moral..docxgertrudebellgrove
- write one 5-7 page paper about All forms of Euthanasia are moral.
- Argumentative/Persuasive paper structure
- Include an introduction and conclusion. The main points of your paper should be identified in
the introduction.
- include at least three arguments to support the position
- Include at least one opposing argument against your topic
- times new roman font
- double spaced
- 12 point font size
- work cited page
.
-1st Play name is BERNHARDTHAMLET -2nd Play name is READY ST.docxgertrudebellgrove
-1st Play name is "BERNHARDT/HAMLET "
-2nd Play name is "READY STEADY YETI GO"
PREVIEW PAPER GUIDELINES
1. Title of Show
2. Playwright (and, if musical, Composer, Librettist)
3. Creative Team: Lead actors, Director, Designers (if musical, Choreographer and Music Director)
4. Venue: Broadway, Off-Broadway, College, etc. (incl. # of seats, cost of a regular ticket
5. Audience: (that is, what demographic is the production trying to attract?) Whom do you think would come and enjoy the performance?
Substantiate this claim by citing advertising evidence--type of ad, where it is advertised (e.g., NY Times, TimeOut New York, Internet, radio)
6. In one sentence, what's the story about?
7. In three sentences, what is your expectation? E.g., Deliriously excited? Modestly intrigued? Morbidly curious? Apathetic? Anxiously anticipating? Horrifically terrified? Dolefully dreading? And why?
.
. 1. Rutter and Sroufe identified _____________ as one of three impo.docxgertrudebellgrove
. 1. Rutter and Sroufe identified _____________ as one of three important areas of focus in the future of developmental psychopathology.
A. How cause and effect underlie childhood disorders
B. The role of the media in the life of the modern child.
C. Creating a stricter definition of normal behavior.
D. Fetal development’s influence on childhood behavior
2. Which of the following questions is not appropriate on a mental status exam?
A. What’s four times five?
B. Who’s the current president of the United States?
C. What day of the week is it today?
D. Who wrote the Harry Potter books?
3. State laws can influence decision making in all the following ways, except
A. who can legally provide consent for the child.
B. beneficence and maleficence
C. timelines for reporting suspected child abuse
D. custodial versus noncustodial parental rights
4. The transactional model was developed to
A. illustrate how even very disabled children are able to adapt to their environments.
B. analyze exactly which characteristics are passed from a caregiver to a child.
C. predict the future of a child’s development by analyzing past events and behaviors.
D. show how a child adapts to an environment and how the environment changes as a result.
5. All of the following are true concerning the APA 10 ethical standards except
A. the standards were useful in past decades but are no longer useful.
B. the standards address appropriate advertising and displays of public information.
C. the standards address matters pertaining to research and publication.
D. the standards assist professionals to resolve ethical issues.
6. Which of the following is true regarding the age of majority?
A. It’s 18 in 34 of the U.S. States.
B. It’s 19 years in all Canadian provinces.
C. It’s 18 years of age in every USA State
D. It’s not an important consideration for psychologists working with children.
7. In the context of Sue’s 2006 article on cultural competent treatment, gift giving refers to
A. giving a token gift to the client
B. rules about barbering
C. accepting a gift from the client
D. gifts of therapy, such as reduced tension
8. Which of the following is one of the guiding principle of the American Psychological Association (APA).
A. Generosity
B. Duplicity
C. Felicity
D. Integrity
9. Mash and Wolfe (2002) suggest three goals of assessment . Which of the following is not one of the goals?
A. Diagnosis
B. Treatment planning
C. Prognosis
D. Research
10. Using the K-3 Paradigm involves knowledge of
A. brain chemistry
B. the Diagnostic and Statistical Manual of Mental Disorders
C. a child’s family medical history
D. developmental expectations
12. Which of the following is true regarding a functional behavioral assessment?
A. An FBA assesses the degree to which a behavior exists.
B. An FBA is norms-based.
C. The FBA was developed to analyzed why a behavior exists.
D. The use of FBA has been discouraged by the American Psycholo.
-Prior to the Civil War, how did the (dominant) discourse over the U.docxgertrudebellgrove
-Prior to the Civil War, how did the (dominant) discourse over the United States’ future reach a crisis point? What were the arguments regarding the Constitutionality of slavery and notions of citizenship? How did relative definitions of liberty/freedom/equality become irreconcilable?
.
- Using the definition Awareness of sensation and perception to ex.docxgertrudebellgrove
- Using
the definition Awareness of sensation and perception to explain why or why not dolphins have consciousness
!
-
two to three paragraph explanation
-
Specify the definition you are using.
Then demonstrate appropriate application of that definition.
- You should describe the creature you are exploring and its behavior for those unfamiliar with it.
- Stick to behaviors that are relevant to whether the creature has consciousness or not under your chosen definition.
- The behavior must be observable! You declaring that a creature "looks fearful/happy/sad" is not on observation, it's an opinion.
- Present arguments that illustrates your position.
* For example, "Research has shown (citation if available can help) that Orangutans can recognize themselves in the mirror and realize the image they see is a reflection of themselves. This suggests they have awareness of their themselves as separate from the environment and others."
.
- should include an introduction to the environmental issue and its .docxgertrudebellgrove
- should include an introduction to the environmental issue and its location
- next portion should be about the opposing views (atleast 3 cons. and 3 possible solutions to the cons) The cons needs to be focused on the environmental impact of the problem, not just how it's affecting humans. What is it doing to the ecosystems?
- must be 4 pages double-spaced not including references and include in-text citation
-not opinion based!!
.
- FIRST EXAM SPRING 20201. Describe how the view of operations.docxgertrudebellgrove
- FIRST EXAM SPRING 2020
1. Describe how the view of operations as a process can be applied to the following:
a. Acquisition of another company
b. Marketing Research for a New Product
c. Design of an Information System
2. An operations manager was heard complaining
“My boss never listens to me ----- all the boss wants from me is to avoid making waves. I rarely get any capital to improve operations. Also, we do not have weekly, biweekly or even monthly meetings with our product managers, supply chain department, customer service or the sales department. We only meet with the accounting and finance departments when there are issues with the monthly budgets. Furthermore, our department has interacted with information service department about four times in past fiscal year”
Please assess the following:
a. Whether this business has a business strategy ?
b. Does it have an operations strategy?
c. What would you recommend?
3. Firm A has recorded the following costs in 2018:
Incoming materials and inspection $20,000
Training of Personnel $40,000
Warranty $45,000
Process Planning $15,000
Scrap $13,000
Quality Laboratory $30,000
Rework $25,000
Allowances $10,000
Complaints $14,000
a. What are the Prevention, Appraisal, Internal Failure and External Failure costs?
b. What inferences can you draw on Quality Measures taken by Firm A?
c. What would you recommend to improve quality programs in Firm A?
d. What initiatives should Firm A implement for 2019 and 2020?
4. Please explain the House of Quality (QFD) as discussed in class.
5. A certain process is under statistical control and has a mean value of 130 and a standard deviation of 8. The specifications for the process are:
a. USL (upper specification limit) = 150
b. LSL(lower specification limit) =100
a. Calculate the cp and cpk
b. Which of these indices is a better measure of process capability and why?
c. Assuminng a normal distribution what percentage of output is expected to fall ourside the specification. Why is it important to know this?
d. What would you recommend?
2
Chapter 7
Government Ethics
and the Law
William A. Myers, Ph.D.
Learning Objectives (1 of 2)
• Describe some of the reasons why there has
been a loss of trust in government.
• Explain the purpose of various government
committees on ethics.
• Discuss how public policy protects the rights of
citizens.
Learning Objectives (2 of 2)
• Describe federal laws designed to protect each
individual’s rights.
• Explain the concept of political malpractice.
• Understand the importance of ethics in public
service.
Let every American, every lover of liberty, every
well wisher to his posterity, swear by the blood
of the Revolution, never to violate in the least
particular, the laws of the country; and never to
tolerate their violation by others.
—Abraham Lincoln
Executive Branch:
U.S. Office of Government Ethics
• Exercises leadership .
- Considering the concepts, examples and learning from the v.docxgertrudebellgrove
- Considering the concepts, examples and learning from the various modules you have attended this year, summarise and reflect on in a critical way what you think are the key elements (both internal and external to businesses) that organisations should consider to develop and grow responsibly and effectively in today’s economy.
.
- Discuss why a computer incident response team (CIRT) plan is neede.docxgertrudebellgrove
- Discuss why a computer incident response team (CIRT) plan is needed, and its purpose.
- Why are the roles and responsibilities important to be listed and kept updated for a CIRT plan.
- Connect the dots: Discuss your understanding of the CIRT incident handling procedures, the role policies play, and the importance of communication escalation procedures.
- What are some best practices for implementing a CIRT plan? Do some personal research to answer this questions.
.
- Discuss why a computer incident response team (CIRT) plan is n.docxgertrudebellgrove
- Discuss why a computer incident response team (CIRT) plan is needed, and its purpose.
- Why are the roles and responsibilities important to be listed and kept updated for a CIRT plan.
- Connect the dots: Discuss your understanding of the CIRT incident handling procedures, the role policies play, and the importance of communication escalation procedures.
- What are some best practices for implementing a CIRT plan? Do some personal research to answer this questions.
.
- 2 -Section CPlease write your essay in the blue book.docxgertrudebellgrove
- 2 -
Section C
Please write your essay in the blue book.
Write an informal narrative about "some" composing process of yours. Essentially, you will write a Reflective Self-Evaluation of yourself as a college writer. What exactly does that mean? It requires you to:
a. look back over a recently completed process
b. think reflectively about that process
c. critically evaluate what went well, what didn’t go well, or what you might have done differently
As the aforementioned examples suggest, reflective writing is writing that describes, explains, interprets, and evaluates any past performance, action, belief, feeling, or experience. To reflect is to turn or look back, to reconsider something in the past from the perspective of the present. So, in your final essay, you will reflect and make an evaluation of your experience in this course.
Remember, reflection involves multiple angles of vision. Just as light waves are thrown or bent back from the surface of a mirror, so, too, reflective writing throws our experience, action, or performance back to us, allowing us to see differently. We view the past from the angle of the present, what was from the angle of what could have been or what might be. Multiplying your angle of vision through reflection often yields new insights and more complicated (complex) understanding of the issue on which you are reflecting.
Professors generally look for four kinds of knowledge in reflective self-evaluation essays: self-knowledge, content knowledge, rhetorical knowledge, and critical knowledge (aka judgment). Following are ideas for each of these types of knowledge, which may be used to generate ideas for your essay. Choose only a few of the questions to respond to, questions that allow you to explain and demonstrate your most important learning for the course.
You may write about your composing process for academic papers or creative genres or a combination of both. Reflect as thoroughly as possible upon your writing process and explain it. Your narrative should include whatever you DO when you write, as well as whatever you DO when you compose. Composing should be understood in the broad sense, i.e. composing goes on in your mind when you are cleaning your refrigerator, mowing your grass, etc. It also occurs when you are researching, taking notes, or procrastinating. In essence you are NEVER NOT composing something. So the key to your reflections is to include everything you do that makes a difference in your writing, from having to use a certain pen, to listening to music or sitting in the library. Both your formal and informal processes impact the way you produce a written work, if you use a formal method of note taking or outlining, if you compose on the computer or with pen and paper explore any and all of these activities that are helpful to you in your process. Explore all possible aspects that apply. This is a useful exercise for now and for you to revisit and revise in the future .
- Confidence intervals for a population mean, standard deviation kno.docxgertrudebellgrove
- Confidence intervals for a population mean, standard deviation known
- Confidence intervals for a population mean, standard deviation unknown
-Confidence intervals for population proportion
- Confidence intervals for a standard deviation
.
) Create a new thread. As indicated above, select two tools describ.docxgertrudebellgrove
) Create a new thread. As indicated above, select two tools described in chapter 7 from different categories, and describe how these tools could be used to develop a policy for optimizing bus and local train schedules to minimize energy use and passenger wait times in a SmartCity environment.
tools
•Visualization
•Argumentation
•eParticipation
•Opinion mining
•Simulation
•Serious games
•Tools specifically designed for policy makers
•Persuasive
•Social network analysis (SNA)
•Big data analytics
•Semantics and linked data
.
(Write 3 to 4 sentences per question) 1. Describe one way y.docxgertrudebellgrove
(Write 3 to 4 sentences per question)
1.
Describe one way you can leverage any strengths you have in research and information literacy to promote your success.
Consider successes, lessons learned, or skills you have gained as a result of your past academic, personal, or professional experiences.
2.
1.
Why do you think it is important to use source materials to support your viewpoints?
Why is it important that the sources you use in your coursework be scholarly sources?
.
( America and Venezuela) this is a ppt. groups assignment. Below is .docxgertrudebellgrove
( America and Venezuela) this is a ppt. groups assignment. Below is my part.
Explain how an American would apply the knowledge of verbal and nonverbal communication to foster effective cross-cultural communication within the selected country.
Lastly, summarize how cultural differences affect cross-cultural communications.
.
++ 2 PAGES++Topic Make a bill to legalize all felon has the rig.docxgertrudebellgrove
++ 2 PAGES++
Topic: Make a bill to legalize all felon has the right to vote with no condition (become a green state) https://www.aclu.org/issues/voting-rights/voter-restoration/felony-disenfranchisement-laws-map
Guideline: **only do part 2 (3-55)** follow guideline on this website: https://leg.wa.gov/CodeReviser/Documents/2019BillDraftingGuide.pdf
additional websites (or you can search more info beside the websites i provide):
https://www.sos.wa.gov/elections/voters/felons-and-voting-rights.aspxhttps://www.sos.wa.gov/elections/voter-eligibility.aspx
.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
1. /*************** YOU SHOULD NOT MODIFY ANYTHING
IN THIS FILE ***************/
/*
A simple testrunner framework
Original Author: L. Angrave
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include "testrunner.h"
/* Constants */
#define false (0)
#define true (1)
#define test_killed (2)
/* defaults */
static int default_timeout_seconds = 15;
static int timeout_seconds;
void set_testrunner_default_timeout(int s)
{
assert(s > 0);
default_timeout_seconds = s;
}
void set_testrunner_timeout(int s)
2. {
assert(s > 0);
timeout_seconds = s;
}
/* --- Helper macros and functions --- */
#define DIE(mesg)
{fprintf(stderr,"n%s(%d):%sn",__fname__,__LINE__,mesg);
exit(1);}
static int eql(const char *s1, const char *s2)
{
return s1 && s2 && !strcmp(s1, s2);
}
/* Callback function for qsort on strings */
static int mystrcmp(const void *p1, const void *p2)
{
return eql((const char *) p1, (const char *) p2);
}
/* Stats of all tests run so far */
typedef struct {
int ran, passed, failed;
} stats_t;
/* -- Signal handlers -- */
static pid_t child_pid;
static int sent_child_timeout_kill_signal;
static void kill_child_signal_handler(intsigno)
{
if (!child_pid)
return;
char m[] = "-Timeout(Killing test process)-";
write(0, m, sizeof(m) - 1);
kill(child_pid, SIGKILL);
3. sent_child_timeout_kill_signal = 1;
}
/* Internal function to run a test as a forked child. The child
process is terminated if it runs for more than a few seconds */
static int invoke_test_with_timelimit(testentry_t * test,
int redirect_stdouterr, int argc,
const char **argv)
{
char fname[255];
int wait_status;
pid_t wait_val;
struct sigaction action;
assert(!child_pid);
assert(test && test->test_function && test->name);
set_testrunner_timeout(default_timeout_seconds);
errno = 0;
child_pid = fork();
if (child_pid == -1) {
fprintf(stderr, "-fork failed so running test inline-");
return test->test_function(argc, argv);
}
if (child_pid == 0) {
if (redirect_stdouterr) {
snprintf(fname, (int) sizeof(fname), "stdout-%s.txt",
test->name);
fname[sizeof(fname) - 1] = 0;
freopen(fname, "w", stdout);
4. memcpy(fname + 3, "err", 3);
freopen(fname, "w", stderr);
}
exit(test->test_function(argc, argv));
} else {
wait_status = -1;
sigemptyset(&action.sa_mask);
action.sa_handler = kill_child_signal_handler;
sigaction(SIGALRM, &action, NULL);
sent_child_timeout_kill_signal = 0;
alarm(timeout_seconds);
wait_val = waitpid(child_pid, &wait_status, 0);
int child_exited_normally = WIFEXITED(wait_status);
int child_exit_value = WEXITSTATUS(wait_status);
int child_term_by_signal = WIFSIGNALED(wait_status);
int child_term_signal = WTERMSIG(wait_status);
if (child_term_by_signal) {
fprintf(stderr, "testrunner:Test terminated by signal
%dn",
child_term_signal);
fprintf(stderr,
"testrunner:waitpid returned %d
(child_pid=%d,wait_status=%d)",
wait_val, child_pid, wait_status);
}
if (child_pid != wait_val)
fprintf(stderr,
"testrunner: strange... wait_val != child_pidn");
int passed = (child_pid == wait_val) && (child_exit_value
== 0)
5. && (child_exited_normally != 0);
alarm(0);
kill(child_pid, SIGKILL);
child_pid = 0;
return sent_child_timeout_kill_signal ? test_killed : passed
? 0 :
1;
}
}
/*
* run a test and update the stats. The main guts of this
functionality is provided by invoke_test_with_timelimit
* This outer wrapper updates thes output and statistics before
and after running the test.
*/
static int
run_one_test(stats_t * stats, testentry_t * test, int
redirect_stdouterr,
int argc, const char **argv)
{
int test_result;
assert(stats && test->name && argc > 0 && argv && *argv);
stats->ran++;
stats->failed++;
printf("%2d.%-20s:", stats->ran, test->name);
fflush(stdout);
test_result =
invoke_test_with_timelimit(test, redirect_stdouterr, argc,
6. argv);
if (test_result == 0) {
stats->failed--;
stats->passed++;
}
printf(":%sn", (test_result == 0 ? "pass" : test_result ==
2 ? "TIMEOUT * " : "FAIL *"));
return test_result != 0;
}
/* Help functionality to print out sorted list of test names and
suite names */
static void print_targets(testentry_t tests[], int count)
{
const char **array;
const char *previous;
int i;
array = (const char **) calloc(sizeof(const char *), count);
/* Sort the test names and print unique entries */
for (i = 0; i < count; i++)
array[i] = tests[i].name;
qsort(array, count, sizeof(array[0]), mystrcmp);
printf("nValid tests : all");
for (i = 0, previous = ""; i < count; i++)
if (!eql(previous, array[i]))
printf(" %s", (previous = array[i]));
/* Sort the suite names and print unique entries */
for (i = 0; i < count; i++)
array[i] = tests[i].suite;
7. qsort(array, count, sizeof(array[0]), mystrcmp);
printf("nValid suites:");
for (i = 0, previous = ""; i < count; i++)
if (!eql(previous, array[i]))
printf(" %s", (previous = array[i]));
printf("n");
}
/*
* Main entry point for test harness
*/
int
run_testrunner(int argc, const char **argv, testentry_t tests[],
int test_count)
{
const char *test_name, *target;
int i;
stats_t stats;
int target_matched, max_errors_before_quit,
redirect_stdouterr;
memset(&stats, 0, sizeof(stats));
max_errors_before_quit = 1;
redirect_stdouterr = 0;
assert(tests != NULL);
assert(test_count > 0);
assert(argc > 0 && argv && *argv);
while (true) {
target = argc > 1 ? argv[1] : "";
assert(target);
if (*target != '-')
10. 1%
PUBLICATIONS
100%
STUDENT PAPERS
1 100%
Exclude quotes Off
Exclude bibliography On
Exclude matches Off
Norah
ORIGINALITY REPORT
PRIMARY SOURCES
Submitted to Cypress Fairbanks Independent
School District
Student Paper
Norahby Mohammed AlzahraneNorahORIGINALITY
REPORTPRIMARY SOURCES
Outline
STEM Teaching at the Elementary school
RQ: How do we prepare preservice teachers to engage in STEM
teaching at the elementary?
Introduction
a-Introduce the topic of STEM Teaching at the Elementary
11. school
b-Cite real life Example and case study
Definitions of terms
A- Contrasting definitions of traditional STEM
B- Flesh out what scholars’ definition of STEM
C-
Outline
STEM Teaching at the
Elementary school
RQ: How do we prepare preservice teachers to engage in STEM
teaching at the
elementary?
Introduction
a
-
Introduce
the topic of
STEM Teaching at the Ele
mentary school
b
-
Cite real life Example
and
12. case study
D
efinitions of t
erms
A
-
Contrasting d
efinitions
of traditional
STEM
B
-
Flesh out wha
t
scholars’
definition of STEM
C
-
Outline
STEM Teaching at the Elementary school
RQ: How do we prepare preservice teachers to engage in STEM
teaching at the
elementary?
13. Introduction
a-Introduce the topic of STEM Teaching at the Elementary
school
b-Cite real life Example and case study
Definitions of terms
A- Contrasting definitions of traditional STEM
B- Flesh out what scholars’ definition of STEM
C-
Literature review -Summaries
STEM Teaching at the Elementary school
RQ: How do we prepare preservice teachers to engage in STEM
teaching at the elementary?
Science, Technology, Engineering and Mathematics (STEM)
Author/Title
Purpose
Sample
Results
Implications
1
Supporting Elementary Pre-Service Teachers to Teach STEM
Through Place-Based Teaching and Learning Experiences
Anne E. Adams
University of Idaho
Brant G. Miller
University of Idaho
Melissa Saul
14. University of Hawai'i - West O'ahu
Jerine Pegg
University of Alberta
Many elementary teachers feel less knowledgeable
about STEM content and less comfortable teaching STEM than
other subjects.
Data were collected on elementary preservice teachers’
perceptions of their experiences as they participated in,
planned, and enacted
integrated place-based STEM education lessons.
Findings indicate that experiences with STEM
learning and teaching through integrated, place-based activities
had a positive impact on preservice teachers’ understanding of
place-based approaches, their perceived ability, and projected
intent to design and implement place-based STEM learning
activities.
In order to prepare teachers to meet the challenges of a rapidly
changing human
15. landscape, we, as teacher educators, need to provide authentic,
and meaningful experiences that
are situated in place, build community, and show pre-service
teachers that they have resources
and partners eager to support the educational mission of
community schools beyond the walls of
their school buildings.
Our findings suggest that within teacher education courses,
methods instructors can
and should employ place-based pedagogy as a way to increase
knowledge of STEM related
elementary teachers’ comfort with learning and teaching STEM
content; and prepare pre-service
teachers for effectively using local spaces for inquiry
instruction
2
Examining Elementary Pre-service Teachers’ Science,
Technology,
Engineering, and Mathematics (STEM) Teaching Intention
Güney Hacıömeroğlu1
16. 3
Taiwanese Preservice Teachers’ Science, Technology,
Engineering, and Mathematics Teaching Intention
Kuen-Yi Lin
P. John Williams
International Journal of Science and Mathematics Education
August 2016,
4
Makerspace and reflective practice: Advancing pre-service
teachers in STEM education
Blackley, Susan; Sheffield, Rachel; Maynard, Nicoleta; Koul,
Rekha; Walker, Rebecca
Australian Journal of Teacher Education (Online)
(2017)
5
17. Using a Makerspace approach to engage Indonesian primary
students with STEM
Susan Blackley Curtin University, Australia Yuli
Rahmawati, Ella Fitriani Universitas Negeri Jakarta, Indonesia
Rachel Sheffield and Rekha Koul Curtin University, Australia
Issues in Educational Research, 2018
6
Robotics to promote elementary education pre-service teachers'
STEM engagement, learning, and teaching
Kim, C., Kim, D., Yuan, J., Hill, R. B., Doshi, P., & Thai, C. N.
(2015). Computers & Education, 91, 14-31.
7
An Integrated Model for STEM Teacher
Preparation: The Value of a Teaching Cooperative
Educational Experience
Ellen W. Eckman
18. Marquette University
Mary Allison Williams
Marquette University
This study aims at examining elementary pre-service teachers’
integrative STEM intentions.
This study applies the theory of planned behavior as a basis for
exploring the impact of knowledge, values, subjective norms,
perceived behavioral controls, and attitudes on the behavioral
intention toward (STEM) education among Taiwanese
preservice science teachers.
The research presented in this paper describes a type of
Makerspace that is defined by its purpose: to improve the
confidence and ability of primary education students in STEM
education.
19. Examines the learning experiences integrated STEM project
purpose of helping teachers learn how to design and implement
(STEM) lessons using robotics.
20. The purpose of this article is to evaluate an intensive, integrated
model for teacher
preparation, specifically, a preservice STEM teacher education
model
Quantitative study, data were gathered from 401 elementary
pre-service teachers who were enrolled
in two public universities.
Questionnaires (N = 139) collected information on the
behavioral intention of preservice science teachers engaging in
STEM education. Data were analyzed using descriptive
statistics, path analysis, and analysis of variance.
21. a large set of qualitative data was collected, this paper reports
on the progress and reflections of the teacher education
students, and shares insights into their personal learning and
development as teachers.
9 female teacher education students and 71 schoolgirls in Years
5 and 6
Examines the learning experiences of 291 Year 5 and 6
Indonesian primary school students, across four schools in
North Jakarta, who participated in an integrated STEM project
Data were collected from surveys, classroom observations,
interviews, and lesson plans. Both quantitative and qualitative
data analyses indicated that pre-service teachers engaged in
robotics activities actively and mindfully.
22. STEM preservice teachers
participated in a cooperative teaching experience which placed
them at the school site
for their university course work and field placements, thus
ensuring a more seamless
connection between theory and practice.
Findings of this study showed that
there was no significant difference between pre-service
teachers’ scores on knowledge, attitude,
value perceived behavioral control, and behavioral intention
regarding gender.
However, there was
a significant difference between pre-service teachers’ scores on
subjective norm regarding gender.
Results revealed that, in terms of direct effects, higher
perceived behavioral control and subjective norms were
associated with stronger STEM teaching intention. More
positive attitude and greater knowledge were indirectly
associated with higher subjective norms and perceived
behavioral control, which resulted in stronger STEM teaching
intention
23. The results indicated that a Makerspace approach was very
effective in engaging students in the STEM space, and students
were also challenged to work collaboratively in groups
mentored by pre-service teachers.
analyses indicated that pre-service teachers engaged in robotics
activities actively and mindfully. Their STEM engagement
improved overall. Their emotional engagement (e.g., interest,
enjoyment) in STEM significantly improved and in turn
24. influenced their behavioral and cognitive engagement in STEM.
The findings from this comparative study of
the STEM preservice students in the teaching co-op and STEM
preservice teachers in a
traditional preparation model indicates that the STEM
preservice teachers in the teaching
cooperative model - - were more confident about their teaching
skills, more comfortable with
their content knowledge, and prepared to work effectively with
high-needs students
Using STEM activities in classroom environment would allow
opportunities for pre-service teachers to become effective
elementary teachers. Throughout the longitudinal
research studies,
observation notes can be taken, and interviews would be
conducted to investigate
elementary pre-service teachers’ STEM teaching intentions
deeply.
The most important factors appeared to include developing
preservice teachers’ (a) positive appreciation regarding STEM
outcomes and teaching and (b) competency in resolving
difficulties related to STEM teaching
25. STEM teacher education programs must stress developing
preservice teachers’ behavioral intention toward STEM teaching
and related socioaffective factors and not just emphasize
developing their knowledge in science, technology, engineering,
and mathematics
With the application of STEM knowledge and skills, we also
posit that the Makerspace approach is effective in the
acquisition and demonstration of 21st century skills: problem-
26. solving, critical and creative thinking, collaboration, and
communication.
suggest that robotics can be used as a technology in activities
designed to enhance teachers' STEM engagement and teaching
through improved attitudes toward STEM
Literature review
-
Summaries
STEM
Teaching at the Elementary school
RQ:
How do we prepare preservice teachers to engage in STEM
teaching at the elementary?
Science, Technology, Engineering and Mathematics (STEM)
Author/Title
Purpose
Sample
27. Results
Implications
1
Supporting Elementary Pre
-
Service Teachers to Teach
STEM Through Place
-
Based
Teaching
and Learning
Experiences
Anne E. Adams
University of Idaho
Brant G. Miller
University of Idaho
Melissa Saul
University of Hawai'i
-
28. West
O'ahu
Jerine Pegg
University of Alberta
M
any elementary
teachers feel less
knowledgeable
about STEM
content and less
comfortable
teaching STEM
than other
subjects.
Data were
collected on
elementary
preservice
teachers’
pe
rceptions of
their experiences
as they
participated in,
planned, and
29. enacted
integrated place
-
based STEM
education lessons.
Findings indicate that
experiences with
STEM
learning and teaching
through integrated,
place
-
based activities
had a
positive impact
on preservice teachers’
understanding of place
-
based approaches, their
perceived ability, and
projected
intent to design and
implement place
30. -
based
STEM learning
activities.
In order to prepare
teachers to meet the
challenges of a
rapidly changing
human
landscape, we, as
teacher educators,
need to provide
authentic, and
meaningful
experiences that
are situated in place,
build community, and
show pre
-
service
teachers that they
have resources
and partners eager to
support the
educatio
nal mission
of community
schools beyond the
walls of
31. their school
buildings.
Our findings suggest
that within teacher
education courses,
methods instructors
can
and should employ
place
-
based
pedagogy as a way to
increase knowledge
of STEM related
element
ary teachers’
comfort with learning
and teaching STEM
content; and prepare
pre
-
service
Literature review -Summaries
STEM Teaching at the Elementary school
RQ: How do we prepare preservice teachers to engage in STEM
teaching at the elementary?
Science, Technology, Engineering and Mathematics (STEM)
Author/Title Purpose Sample Results Implications
32. 1
Supporting Elementary Pre-
Service Teachers to Teach
STEM Through Place-Based
Teaching and Learning
Experiences
Anne E. Adams
University of Idaho
Brant G. Miller
University of Idaho
Melissa Saul
University of Hawai'i - West
O'ahu
Jerine Pegg
University of Alberta
Many elementary
teachers feel less
knowledgeable
about STEM
content and less
comfortable
teaching STEM
than other
subjects.
Data were
33. collected on
elementary
preservice
teachers’
perceptions of
their experiences
as they
participated in,
planned, and
enacted
integrated place-
based STEM
education lessons.
Findings indicate that
experiences with
STEM
learning and teaching
through integrated,
place-based activities
had a positive impact
on preservice teachers’
understanding of place-
based approaches, their
perceived ability, and
projected
intent to design and
implement place-based
34. STEM learning
activities.
In order to prepare
teachers to meet the
challenges of a
rapidly changing
human
landscape, we, as
teacher educators,
need to provide
authentic, and
meaningful
experiences that
are situated in place,
build community, and
show pre-service
teachers that they
have resources
and partners eager to
support the
educational mission
of community
schools beyond the
walls of
their school
buildings.
Our findings suggest
that within teacher
education courses,
methods instructors
can
and should employ
35. place-based
pedagogy as a way to
increase knowledge
of STEM related
elementary teachers’
comfort with learning
and teaching STEM
content; and prepare
pre-service
Literature Review for a Study or a Professional Development
Presentation -7 pg
· Literature Review 7-
· Outline for the study
Goal: To ground a research question/professional development
presentation within a framework of extant literature (i.e.,
Review of the Literature). The topics for the study/professional
development must fall under one of the Principles to Actions
Eight Effective Mathematics Teaching Practices. This major
course project provides an opportunity for you to become an
expert on a topic related to mathematics teaching or teacher
education.
IMPORTANT NOTE: In order to complete this assignment
successfully, you must follow the guidelines provided in Galvan
(2014) Writing Literature Reviews. This book guides you
through the entire process from planning, conducting the
review, and writing the document. This assignment prepares you
for the technical writing style expected by the profession. In
addition, the mechanics for how you write (i.e., sentence
structure, word choice, citations, etc.) must adhere to the
standards outlined in the APA Styles Manual.
Although general teacher education literature may be used for
the literature review, the focus should be on the impact of the
topic on mathematics teaching and/or learning. Also, the review
36. of the literature should focus primarily on empirically grounded
research (quantitative, qualitative, or mixed methods). As part
of this effort, we will review and critique each other’s work.
Literature Review
for a Study or a Professional Development Presentation
-
7 pg
-
Literature
Review 7
-
-
Outline
for the study
Goal: To ground a research question/professional development
presentation within a framework of
extant literature (i.e., Review of the Literature). The topics for
the study/professional development must
fall under one of the Principles to Actions Eight Ef
37. fective Mathematics Teaching Practices. This major
course project provides an opportunity for you to become an
expert on a topic related to mathematics
teaching or teacher
education.
IMPORTANT NOTE: In order to complete this assignment
successfully, yo
u must follow the guidelines
provided in Galvan (2014) Writing Literature Reviews. This
book guides you through the entire process
from planning, conducting the review, and writing the
document. This assignment prepares you for the
technical writing style
expected by the profession. In addition, the mechanics for how
you write (i.e.,
sentence structure, word choice, citations, etc.) must adhere to
the standards outlined in the APA Styles
Manual.
Although general teacher education literature may be used
for the literature review, the focus should be
on the impact of the topic on mathematics teaching and/or
learning. Also, the review of the literature
should focus primarily on empirically grounded research
(quantitative, qualitative, or mixed methods).
As
part of this effort, we will review and critique each other’s
work.
38. Literature Review for a Study or a Professional Development
Presentation -7 pg
- Literature Review 7-
- Outline for the study
Goal: To ground a research question/professional development
presentation within a framework of
extant literature (i.e., Review of the Literature). The topics for
the study/professional development must
fall under one of the Principles to Actions Eight Effective
Mathematics Teaching Practices. This major
course project provides an opportunity for you to become an
expert on a topic related to mathematics
teaching or teacher education.
IMPORTANT NOTE: In order to complete this assignment
successfully, you must follow the guidelines
provided in Galvan (2014) Writing Literature Reviews. This
book guides you through the entire process
from planning, conducting the review, and writing the
document. This assignment prepares you for the
technical writing style expected by the profession. In addition,
the mechanics for how you write (i.e.,
sentence structure, word choice, citations, etc.) must adhere to
the standards outlined in the APA Styles
Manual.
Although general teacher education literature may be used for
the literature review, the focus should be
on the impact of the topic on mathematics teaching and/or
learning. Also, the review of the literature
should focus primarily on empirically grounded research
(quantitative, qualitative, or mixed methods).
As part of this effort, we will review and critique each other’s
work.
39. /*************** YOU SHOULD NOT MODIFY ANYTHING
IN THIS FILE ***************/
#define _GNU_SOURCE
#include <stdio.h>
#undef _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "testrunner.h"
#include "list.h"
#include "scheduler.h"
#include "worker.h"
//#define quit_if(cond) do {if (cond) exit(EXIT_FAILURE);}
while(0)
#define quit_if(cond) do {if (cond) {printf("Line
%d.",__LINE__);exit(EXIT_FAILURE);}} while(0)
void args_to_nums(int argc, const char **argv, int
*num_workers, int *queue_size, int **quanta) {
int i;
quit_if(argc < 4);
*num_workers = atoi(argv[1]);
*queue_size = atoi(argv[2]);
*quanta = malloc(*num_workers * sizeof(int));
quit_if(*quanta == NULL);
40. for(i=3;i<argc;i++)
quanta[0][i-3] = atoi(argv[i]);
}
void nums_to_args(int num_workers, int queue_size, int
*quanta, int *argc, char ***argv) {
int i;
*argc = num_workers+3;
*argv = malloc(*argc*sizeof(char *));
quit_if(*argv==NULL);
argv[0][0] = "scheduler";
argv[0][1] = malloc(3*sizeof(char));
quit_if(argv[0][1]==NULL);
sprintf(argv[0][1],"%d",num_workers);
argv[0][2] = malloc(3*sizeof(char));
quit_if(argv[0][2]==NULL);
sprintf(argv[0][2],"%d",queue_size);
for(i=0;i<num_workers;i++) {
argv[0][i+3] = malloc(3*sizeof(char));
quit_if(argv[0][i+3]==NULL);
sprintf(argv[0][i+3],"%d",quanta[i]);
}
argv[0][i+3]=NULL;
}
/* Prepare input, reroute file descriptors, and run the program.
*/
void run_test(int argc, const char **argv)
{
//int fork_pid = fork();
//if (fork_pid == 0) {
/* Reroute standard file descriptors */
freopen("smp5.out", "w", stdout);
/* Run the program */
quit_if(smp5_main(argc, argv) != EXIT_SUCCESS);
41. fclose(stdout);
//} else if (fork_pid > 0) {
//waitpid(fork_pid, 0, 0);
//} else {
//fprintf(stderr, "run_test: fork() errorn");
//}
}
int test_output(FILE *stream, int nw, int qs, int *q) {
int queue_size, queue_index;
int num_workers, worker_index;
int rv, in_queue, term, susp;
unsigned long *queue, *workers, tid, prev, newwork, dummyl;
int *remaining, *quanta;
char dummyc;
float tot_wait, tot_run, ave_wait, ave_run;
int my_run, my_wait;
rv = fscanf(stream,"Main: running %d workers with queue size
%d for quanta:n",&num_workers, &queue_size);
quit_if(rv != 2 || num_workers != nw || queue_size != qs);
queue = malloc(queue_size*sizeof(long));
workers = malloc(num_workers*sizeof(long));
quanta = malloc(num_workers*sizeof(int));
remaining = malloc(queue_size*sizeof(int));
for(worker_index=0;worker_index<num_workers;worker_index
++) {
quit_if(fscanf(stream, " %d", quanta+worker_index) != 1);
quit_if(quanta[worker_index]!=q[worker_index]);
}
fscanf(stream,"n");
for(worker_index=0;worker_index<num_workers;worker_index
++) {
quit_if(fscanf(stream, "Main: detaching worker thread
%lu.n",workers+worker_index) != 1);
45. }
quit_if(fscanf(stream, "Th%c",&dummyc) != 1);
if (dummyc=='r') {
quit_if(fscanf(stream, "ead %lu: terminating.nThe",&tid)!=1
|| tid != prev);
}
quit_if(fscanf(stream, " total wait time is %f
seconds.n",&tot_wait) != 1);
quit_if(fscanf(stream, "The total run time is %f
seconds.n",&tot_run) != 1);
quit_if(fscanf(stream, "The average wait time is %f
seconds.n",&ave_wait) != 1);
quit_if(fscanf(stream, "The average run time is %f
seconds.n",&ave_run) != 1);
if (dummyc=='e')
quit_if(fscanf(stream, "Thread %lu: terminating.nThe",&tid)
!= 1|| tid != prev);
quit_if(abs(tot_wait-my_wait)>1);
quit_if(abs(tot_run-my_run)>1);
quit_if(abs(tot_wait/num_workers-ave_wait)>.5);
quit_if(abs(tot_run/num_workers-ave_run)>.5);
return 0;
}
int general_test(int argc, const char **argv) {
FILE *f;
int nw, qs, *q;
run_test(argc,argv);
f = fopen("smp5.out","r");
args_to_nums(argc,argv,&nw,&qs,&q);
test_output(f,nw,qs,q);
return EXIT_SUCCESS;
}
int specific_test(int nw, int qs, int *q) {
FILE *f;
46. int argc;
char **argv;
nums_to_args(nw,qs,q,&argc,&argv);
run_test(argc,(const char **)argv);
f = fopen("smp5.out","r");
test_output(f,nw,qs,q);
return EXIT_SUCCESS;
}
int test_3_1_2_2_2() {
int q[3] = {2,2,2};
return specific_test(3,1,q);
}
int test_2_2_2_2() {
int q[2]={2,2};
return specific_test(2,2,q);
}
int test_5_7_1_2_1_2_1() {
int q[5] = {1,2,1,2,1};
return specific_test(5,7,q);
}
int test_4_1_1_2_3_4() {
int q[4] = {1,2,3,4};
return specific_test(4,1,q);
}
int test_3_3_4_3_2() {
int q[3] = {4,3,2};
return specific_test(3,3,q);
}
/*
47. * Main entry point for SMP% test harness
*/
int run_smp5_tests(int argc, const char **argv)
{
/* Tests can be invoked by matching their name or their
suite name
* or 'all' */
testentry_t tests[] = {
{"test_3_1_2_2_2", "rr", test_3_1_2_2_2},
{"test_2_2_2_2", "rr", test_2_2_2_2},
{"test_5_7_1_2_1_2_1", "rr", test_5_7_1_2_1_2_1},
{"test_4_1_1_2_3_4", "rr", test_4_1_1_2_3_4},
{"test_3_3_4_3_2", "rr", test_3_3_4_3_2},
{"general", "gen", general_test}
};
int result = run_testrunner(argc, argv, tests, sizeof(tests) /
sizeof(testentry_t));
unlink("smp5.out");
return result;
}
/* The real main function. */
int main(int argc, const char **argv)
{
if (argc > 1 && !strcmp(argv[1], "-test")) {
return run_smp5_tests(argc - 1, argv + 1);
} else {
return smp5_main(argc, argv);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
48. #include <errno.h>
#include <time.h>
#include <signal.h>
#include "scheduler.h"
#include "worker.h"
/*
* define the extern global variables here.
*/
sem_t queue_sem; /* semaphore for scheduler queue
*/
thread_info_list sched_queue; /* list of current workers */
static int quit = 0;
static timer_t timer;
static thread_info_t *currentThread= 0;
static long wait_times;
static long run_times;
static int completed = 0;
static int thread_count = 0;
static void exit_error(int); /* helper function. */
static void wait_for_queue();
/****************************************************
***************************
*
* Implement these functions.
*
*****************************************************
*************************/
/*
* This function intializes the queue semaphore and the queue
itself.
49. */
/*
* Update the worker's current running time.
* This function is called every time the thread is suspended.
*/
void update_run_time(thread_info_t *info) {
/* TODO: implement this function */
}
/*
* Update the worker's current waiting time.
* This function is called every time the thread resumes.
*/
void update_wait_time(thread_info_t *info) {
/* TODO: implement this function */
}
static void init_sched_queue(int queue_size)
{
/* set up a semaphore to restrict access to the queue */
sem_init(&queue_sem, 0, queue_size);
/* initialize the scheduler queue */
sched_queue.head = sched_queue.tail = 0;
pthread_mutex_init(&sched_queue.lock, NULL);
/* TODO: initialize the timer */
}
/*
* signal a worker thread that it can resume.
*/
static void resume_worker(thread_info_t *info)
50. {
printf("Scheduler: resuming %lu.n", info->thrid);
/*
* TODO: signal the worker thread that it can resume
*/
/* update the wait time for the thread */
update_wait_time(info);
}
/*send a signal to the thread, telling it to kill itself*/
void cancel_worker(thread_info_t *info)
{
/* TODO: send a signal to the thread, telling it to kill
itself*/
/* Update global wait and run time info */
wait_times += info->wait_time;
run_times += info->run_time;
completed++;
/* Update schedule queue */
leave_scheduler_queue(info);
if (completed >= thread_count) {
sched_yield(); /* Let other threads terminate. */
printf("The total wait time is %f seconds.n",
(float)wait_times / 1000000);
printf("The total run time is %f seconds.n",
(float)run_times / 1000000);
printf("The average wait time is %f seconds.n",
(float)wait_times / 1000000 / thread_count);
printf("The average run time is %f seconds.n",
51. (float)run_times / 1000000 / thread_count);
}
}
/*
* signals a worker thread that it should suspend.
*/
static void suspend_worker(thread_info_t *info)
{
int whatgoeshere = 0;
printf("Scheduler: suspending %lu.n", info->thrid);
/*update the run time for the thread*/
update_run_time(info);
/* TODO: Update quanta remaining. */
/* TODO: decide whether to cancel or suspend thread */
if(whatgoeshere) {
/*
* Thread still running: suspend.
* TODO: Signal the worker thread that it should
suspend.
*/
/* Update Schedule queue */
list_remove(&sched_queue,info->le);
list_insert_tail(&sched_queue,info->le);
} else {
/* Thread done: cancel */
cancel_worker(info);
}
}
/*
52. * this is the scheduling algorithm
* pick the next worker thread from the available list
* you may need to add new information to the thread_info
struct
*/
static thread_info_t *next_worker()
{
if (completed >= thread_count)
return 0;
wait_for_queue();
printf("Scheduler: scheduling.n");
/* return the thread_info_t for the next thread to run */
return sched_queue.head->info;
}
void timer_handler()
{
thread_info_t *info = 0;
/* once the last worker has been removed, we're done. */
if (list_size(&sched_queue) == 0) {
quit = 1;
return;
}
/*suspend the current worker*/
if (currentThread)
suspend_worker(currentThread);
//resume the next worker
info = next_worker();
/* Update currentThread */
currentThread = info;
53. if (info)
resume_worker(info);
else
quit = 1;
}
/*
* Set up the signal handlers for SIGALRM, SIGUSR1, and
SIGTERM.
* TODO: Implement this function.
*/
void setup_sig_handlers() {
/* Setup timer handler for SIGALRM signal in scheduler */
/* Setup cancel handler for SIGTERM signal in workers */
/* Setup suspend handler for SIGUSR1 signal in workers
*/
}
/****************************************************
***************************
*
*
*
*****************************************************
*************************/
/*
* waits until there are workers in the scheduling queue.
*/
static void wait_for_queue()
54. {
while(!list_size(&sched_queue)) {
printf("Scheduler: waiting for workers.n");
sched_yield();
}
}
/*
* runs at the end of the program just before exit.
*/
static void clean_up()
{
/*
* destroy any mutexes/condition variables/semaphores
that were created.
* free any malloc'd memory not already free'd
*/
sem_destroy(&queue_sem);
pthread_mutex_destroy(&sched_queue.lock);
}
/*
* prints the program help message.
*/
static void print_help(const char *progname)
{
printf("usage: %s <num_threads> <queue_size> <i_1, i_2
... i_numofthreads>n", progname);
printf("tnum_threads: the number of worker threads to
runn");
printf("tqueue_size: the number of threads that can be in
the scheduler at one timen");
printf("ti_1, i_2 ...i_numofthreads: the number of quanta
each worker thread runsn");
}
55. /*
* prints an error summary and exits.
*/
static void exit_error(int err_num)
{
fprintf(stderr, "failure: %sn", strerror(err_num));
exit(1);
}
/*
* creates the worker threads.
*/
static void create_workers(int thread_count, int *quanta)
{
int i = 0;
int err = 0;
for (i = 0; i < thread_count; i++) {
thread_info_t *info = (thread_info_t *)
malloc(sizeof(thread_info_t));
info->quanta = quanta[i];
if ((err = pthread_create(&info->thrid, NULL,
start_worker, (void *)info)) != 0) {
exit_error(err);
}
printf("Main: detaching worker thread %lu.n", info-
>thrid);
pthread_detach(info->thrid);
/* TODO: initialize the time variables for each thread
for performance evalution*/
}
}
56. /*
* runs the scheduler.
*/
static void *scheduler_run(void *unused)
{
wait_for_queue();
/* TODO: start the timer */
/*keep the scheduler thread alive*/
while( !quit )
sched_yield();
return NULL;
}
/*
* starts the scheduler.
* returns 0 on success or exits program on failure.
*/
static int start_scheduler(pthread_t *thrid)
{
int err = 0;
if ((err = pthread_create(thrid, NULL, scheduler_run, 0))
!= 0) {
exit_error(err);
}
return err;
}
/*
* reads the command line arguments and starts the scheduler &
worker threads.
57. */
int smp5_main(int argc, const char** argv)
{
int queue_size = 0;
int ret_val = 0;
int *quanta,i;
pthread_t sched_thread;
/* check the arguments. */
if (argc < 3) {
print_help(argv[0]);
exit(0);
}
thread_count = atoi(argv[1]);
queue_size = atoi(argv[2]);
quanta = (int*)malloc(sizeof(int)*thread_count);
if (argc != 3 + thread_count) {
print_help(argv[0]);
exit(0);
}
for ( i = 0; i < thread_count; i++)
quanta[i] = atoi(argv[i+3]);
printf("Main: running %d workers with queue size %d for
quanta:n", thread_count, queue_size);
for ( i = 0; i < thread_count; i++)
printf(" %d", quanta[i]);
printf("n");
/*setup the sig handlers for scheduler and workers*/
setup_sig_handlers();
/* initialize anything that needs to be done for the
scheduler queue. */
58. init_sched_queue(queue_size);
/* creates a thread for the scheduler. */
start_scheduler(&sched_thread);
/* creates the worker threads and returns. */
create_workers(thread_count, quanta);
/* wait for scheduler to finish */
printf("Main: waiting for scheduler %lu.n",
sched_thread);
pthread_join(sched_thread, (void **) &ret_val);
/* clean up our resources */
clean_up();
/* this will wait for all other threads */
pthread_exit(0);
}
long time_difference(const struct timespec *time1, const struct
timespec *time2) {
return (time1->tv_sec - time2->tv_sec) * 1000000 +
(time1->tv_nsec - time2->tv_nsec) / 1000;
}
SMP5: Scheduler with Signals
============================
This MP is a variation of SMP4.
In the last MP, we built a simulated OS process scheduler. The
scheduler can
hold only a certain number of processes (workers) at one time.
Once the process
59. has been accepted into the scheduler, the scheduler decides in
what order the
processes execute. We implemented two scheduling algorithms:
FIFO and Round
Robin.
In this MP, we are to simulate a time-sharing system by using
signals and
timers. We will only implement the Round Robin algorithm.
Instead of using
iterations to model the concept of "time slices" (as in the last
MP), we use
interval timers. The scheduler is installed with an interval
timer. The timer
starts ticking when the scheduler picks a thread to use the CPU
which in turn
signals the thread when its time slice is finished thus allowing
the scheduler
to pick another thread and so on. When a thread has completely
finished its work
it leaves the scheduler to allow a waiting thread to enter. Please
note that in
this MP, only the timer and scheduler send signals. The threads
passively handle
the signals without signaling back to the scheduler.
The program takes a number of arguments. Arg1 determines the
number of jobs
(threads in our implementation) created; arg2 specifies the
queue size of the
scheduler. Arg3 through argN gives the duration (the required
time slices to
complete a job) of each job. Hence if we create 2 jobs, we
should supply arg3
and arg4 for the required duration. You can assume that the
autograder will
60. always supply the correct number of arguments and hence you
do not have to
detect invalid input.
Here is an example of program output, once the program is
complete:
% scheduler 3 2 3 2 3
Main: running 3 workers with queue size 2 for quanta:
3 2 3
Main: detaching worker thread 3075926960.
Main: detaching worker thread 3065437104.
Main: detaching worker thread 3054947248.
Main: waiting for scheduler 3086416816.
Scheduler: waiting for workers.
Thread 3075926960: in scheduler queue.
Thread 3075926960: suspending.
Thread 3065437104: in scheduler queue.
Thread 3065437104: suspending.
Scheduler: scheduling.
Scheduler: resuming 3075926960.
Thread 3075926960: resuming.
Scheduler: suspending 3075926960.
Scheduler: scheduling.
Scheduler: resuming 3065437104.
Thread 3065437104: resuming.
Thread 3075926960: suspending.
Scheduler: suspending 3065437104.
Scheduler: scheduling.
Scheduler: resuming 3075926960.
Thread 3075926960: resuming.
Thread 3065437104: suspending.
Scheduler: suspending 3075926960.
Scheduler: scheduling.
Scheduler: resuming 3065437104.
Thread 3065437104: resuming.
61. Thread 3075926960: suspending.
Scheduler: suspending 3065437104.
Thread 3065437104: leaving scheduler queue.
Scheduler: scheduling.
Scheduler: resuming 3075926960.
Thread 3075926960: resuming.
Thread 3065437104: terminating.
Thread 3054947248: in scheduler queue.
Thread 3054947248: suspending.
Scheduler: suspending 3075926960.
Thread 3075926960: leaving scheduler queue.
Scheduler: scheduling.
Scheduler: resuming 3054947248.
Thread 3054947248: resuming.
Thread 3075926960: terminating.
Scheduler: suspending 3054947248.
Scheduler: scheduling.
Scheduler: resuming 3054947248.
Thread 3054947248: suspending.
Thread 3054947248: resuming.
Scheduler: suspending 3054947248.
Scheduler: scheduling.
Scheduler: resuming 3054947248.
Thread 3054947248: suspending.
Thread 3054947248: resuming.
Scheduler: suspending 3054947248.
Thread 3054947248: leaving scheduler queue.
Thread 3054947248: terminating.
The total wait time is 12.062254 seconds.
The total run time is 7.958618 seconds.
The average wait time is 4.020751 seconds.
The average run time is 2.652873 seconds.
The goal of this MP is to help you understand (1) how signals
and timers work,
62. and (2) how to evaluate the performance of your program. You
will first
implement the time-sharing system using timers and signals.
Then, you will
evaluate the overall performance of your program by keeping
track of how long
each thread is idle, running, etc.
The program will use these four signals:
SIGALRM: sent by the timer to the scheduler, to indicate
another time
quantum has passed.
SIGUSR1: sent by the scheduler to a worker, to tell it to
suspend.
SIGUSR2: sent by the scheduler to a suspended worker, to tell
it to resume.
SIGTERM: sent by the scheduler to a worker, to tell it to
cancel.
You will need to set up the appropriate handlers and masks for
these signals.
You will use these functions:
clock_gettime
pthread_sigmask
pthread_kill
sigaction
sigaddset
sigemptyset
sigwait
timer_settime
timer_create
Also, make sure you understand how the POSIX:TMR interval
63. timer works.
There are two ways you can test your code. You can run the
built-in grading
tests by running "scheduler -test -f0 rr". This runs 5 tests, each
of which can
be run individually. You can also test you program with
specific parameters by
running "scheduler -test gen ..." where the ellipsis contains the
parameters you
would pass to scheduler.
Programming
===========
Part I: Modify the scheduler code (scheduler.c)
-----------------------------------------------
We use the scheduler thread to setup the timer and handle the
scheduling for the
system. The scheduler handles the SIGALRM events that come
from the timer, and
sends out signals to the worker threads.
Step 1.
Modify the code in init_sched_queue() function in scheduler.c
to initialize the
scheduler with a POSIX:TMR interval timer. Use
CLOCK_REALTIME in timer_create().
The timer will be stored in the global variable "timer", which
will be started
in scheduler_run() (see Step 4 below).
64. Step 2.
Implement setup_sig_handlers(). Use sigaction() to install
signal handlers for
SIGALRM, SIGUSR1, and SIGTERM. SIGALRM should
trigger timer_handler(), SIGUSR1
should trigger suspend_thread(), and SIGTERM should trigger
cancel_thread().
Notice no handler is installed for SIGUSR2; this signal will be
handled
differently, in step 8.
Step 3.
In the scheduler_run() function, start the timer. Use
timer_settime(). The
time quantum (1 second) is given in scheduler.h. The timer
should go off
repeatedly at regular intervals defined by the timer quantum.
In Round-Robin, whenever the timer goes off, the scheduler
suspends the
currently running thread, and tells the next thread to resume its
operations
using signals. These steps are listed in timer_handler(), which is
called every
time the timer goes off. In this implementation, the timer
handler makes use of
suspend_worker() and resume_worker() to accomplush these
steps.
Step 4.
Complete the suspend_worker() function. First, update the
info->quanta value.
This is the number of quanta that remain for this thread to
65. execute. It is
initialized to the value passed on the command line, and
decreases as the thread
executes. If there is any more work for this worker to do, send
it a signal to
suspend, and update the scheduler queue. Otherwise, cancel the
thread.
Step 5.
Complete the cancel_worker() function by sending the
appropriate signal to the
thread, telling it to kill itself.
Step 6.
Complete the resume_worker() function by sending the
appropriate signal to the
thread, telling it to resume execution.
Part II: Modify the worker code (worker.c)
------------------------------------------
In this section, you will modify the worker code to correctly
handle the signals
from the scheduler that you implemented in the previous
section.
You need to modify the thread functions so that it immediately
suspends the
thread, waiting for a resume signal from the scheduler. You will
need to use
sigwait() to force the thread to suspend itself and wait for a
resume signal.
You need also to implement a signal handler in worker.c to
66. catch and handle the
suspend signals.
Step 7.
Modify start_worker() to (1) block SIGUSR2 and SIGALRM,
and (2) unblock SIGUSR1
and SIGTERM.
Step 8.
Implement suspend_thread(), the handler for the SIGUSR1
signal. The
thread should block until it receives a resume (SIGUSR2)
signal.
Part III: Modify the evaluation code (scheduler.c)
--------------------------------------------------
This program keeps track of run time, and wait time. Each
thread saves these
two values regarding its own execution in its thread_info_t.
Tracking these
values requires also knowing the last time the thread suspended
or resumed.
Therefore, these two values are also kept in thread_info_t. See
scheduler.h.
In this section, you will implement the functions that calculate
run time and
wait time. All code that does this will be in scheduler.c. When
the program
is done, it will collect all these values, and print out the total
and average
wait time and run time. For your convenience, you are given a
67. function
time_difference() to compute the difference between two times
in microseconds.
Step 9.
Modify create_workers() to initialize the various time variables.
Step 10.
Implement update_run_time(). This is called by
suspend_worker().
Step 11.
Implement update_wait_time(). This is called by
resume_worker().
Questions
==========
Question 1.
Why do we block SIGUSR2 and SIGALRM in worker.c? Why
do we unblock SIGUSR1 and
SIGTERM in worker.c?
Question 2.
We use sigwait() and sigaction() in our code. Explain the
difference between the
two. (Please explain from the aspect of thread behavior rather
than syntax).
Question 3.
When we use POSIX:TMR interval timer, we are using relative
time. What is the
68. alternative? Explain the difference between the two.
Question 4.
Look at start_worker() in worker.c, a worker thread is executing
within an
infinite loop at the end. When does a worker thread terminate?
Question 5.
When does the scheduler finish? Why does it not exit when the
scheduler queue
is empty?
Question 6.
After a thread is scheduled to run, is it still in the sched_queue?
When is it
removed from the head of the queue? When is it removed from
the queue completely?
Question 7.
We've removed all other condition variables in SMP4, and
replaced them with a
timer and signals. Why do we still use the semaphore
queue_sem?
Question 8.
What's the purpose of the global variable "completed" in
scheduler.c? Why do we
compare "completed" with thread_count before we
wait_for_queue() in
next_worker()?
Question 9.
We only implemented Round Robin in this SMP. If we want to
implement a FIFO
scheduling algorithm and keep the modification as minimum,
which function in
69. scheduler.c is the one that you should modify? Briefly describe
how you would
modify this function.
Question 10.
In this implementation, the scheduler only changes threads
when the time quantum
expires. Briefly explain how you would use an additional signal
to allow the
scheduler to change threads in the middle of a time quantum. In
what situations
would this be useful?
#include <stdio.h>
#include "list.h"
/* list helper functions */
int list_size(thread_info_list *list)
{
int cnt = 0;
if (!list) return -1;
pthread_mutex_lock(&list->lock);
list_elem *le = list->head;
while (le) {
cnt++;
le = le->next;
}
pthread_mutex_unlock(&list->lock);
return cnt;
}
71. }
int list_remove(thread_info_list *list, list_elem *old)
{
if (!old || !list) return -1;
pthread_mutex_lock(&list->lock);
if (old->next) {
old->next->prev = old->prev;
}
if (old->prev) {
old->prev->next = old->next;
}
if (list->tail == old) {
list->tail = old->prev;
}
if (list->head == old) {
list->head = old->next;
}
old->next = old->prev = 0;
pthread_mutex_unlock(&list->lock);
return 0;
}
void print_list(thread_info_list *list)
{
pthread_mutex_lock(&list->lock);
list_elem *le = list->head;
while (le) {
printf("0x%X,", (unsigned int)le->info);
le = le->next;
}
pthread_mutex_unlock(&list->lock);
printf("n");
72. }
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include "scheduler.h"
/****************************************************
***************************
*
* Implement these functions.
*
*****************************************************
*************************/
/* Handler for SIGTERM signal */
void cancel_thread()
{
printf("Thread %u: terminating.n", (unsigned
int)pthread_self());
/* signal that done in queue */
sem_post(&queue_sem);
pthread_exit(NULL);
}
/* TODO: Handle the SIGUSR1 signal */
void suspend_thread()
{
73. printf("Thread %u: suspending.n", (unsigned
int)pthread_self());
/*add your code here to wait for a resume signal from the
scheduler*/
printf("Thread %u: resuming.n",(unsigned int)
pthread_self());
}
/****************************************************
***************************
*
*
*
*****************************************************
*************************/
/*
* waits to gain access to the scheduler queue.
*/
static int enter_scheduler_queue(thread_info_t *info)
{
/*
* wait for available room in queue.
* create a new list entry for this thread
* store this thread info in the new entry.
*/
sem_wait(&queue_sem);
list_elem *item = (list_elem*)malloc(sizeof(list_elem));
info->le = item;
item->info = info;
item->prev = 0;
item->next = 0;
list_insert_tail(&sched_queue, item);
return 0;
74. }
/*
* leaves the scheduler queue
*/
void leave_scheduler_queue(thread_info_t *info)
{
printf("Thread %lu: leaving scheduler queue.n", info-
>thrid);
/*
* remove the given worker from queue
* clean up the memory that we malloc'd for the list
* clean up the memory that was passed to us
*/
list_remove(&sched_queue, info->le);
free(info->le);
free(info);
}
/*
* Initialize thread, enter scheduling queue, and execute
instructions.
* arg is a pointer to thread_info_t
*/
void *start_worker(void *arg)
{
thread_info_t *info = (thread_info_t *) arg;
float calc = 0.8;
int j = 0;
/* TODO: Block SIGALRM and SIGUSR2. */
/* TODO: Unblock SIGUSR1 and SIGTERM. */
75. /* compete with other threads to enter queue. */
if (enter_scheduler_queue(info)) {
printf("Thread %lu: failure entering scheduler queue -
%sn", info->thrid, strerror(errno));
free (info);
pthread_exit(0);
}
printf("Thread %lu: in scheduler queue.n", info->thrid);
suspend_thread();
while (1) {
/* do some meaningless work... */
for (j = 0; j < 10000000; j++) {
calc = 4.0 * calc * (1.0 - calc);
}
}
}