Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Non-Deterministic Behavior of a Concurrent System 1. Write a routine which given

ID: 3754123 • Letter: N

Question

Non-Deterministic Behavior of a Concurrent System 1. Write a routine which given a Seed and a Range lim both integers, will generate a random sequence of integers, such that the value of each element in the sequence is within 1 to Range. As discussed in class, you can impose more quence by making the Seed itself generated at random This can be done in several possible ways: eg, using a system clock as the Seed, or soliciting, interactively the value of the Seed during each run "randomness" in the se- 2. For this assignment, write two simple routines, printA and printB where printA and printB print character "A" and "B" respectively 3. Write a Scheduler, which will use the items generated by the random number generator, and depending on the current value of the item, will invoke either the printA or the printB, if the item generated by the random number generator is even or odd Possible Input and Output: . Solicit user choice of Seed and Range . Should display the sequence of random numbers generated; . Should display the sequence of values printed: the user of your system should have ways to Run and Stop the system

Explanation / Answer

ANS 1:

void seq(int seed, int range) { int i; for(i=0;i<10;i++) { printf("%d ", rand()%range); if( rand()%seed< range) { printf("%d ", rand()%seed); }

} }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote