Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the process node (otur process_s) struct maintains their state using the state member. this 16-bit unsigned short that contains information that have been combined

image text in transcribedimage text in transcribed

the process node (otur process_s) struct maintains their state using the state member. this 16-bit unsigned short that contains information that have been combined together using bitwise operations. you are required to use bitwise operators to change the states. | &^ >>> < < state flags crit unused (all 0s) for defunct processes) UR D C 000 description high field name H bit number 15 14 13 12 11 10 9 www exit code 876543210 all flags are individual bits inside of the unsigned short called state in the struct. each bit will either be 0 or a 1. if the bit is a 1, it represents that flag is set. if the bit is a 0, it means that flag is not set. state flags: bits 12-14 represent the current state of the process. (1-bit values) u = running state r = ready state d = defunct state critical flag: bit 11 is a flag representing if the process was set with critical run. (-c) c = critical flag high flag: bit 15 is a flag representing if the process was set with high priority. (-h) h = high flag Bits 0-7 are the lower 8 bits of the Exit Code when the process finished running on the CPU. Otur process s *otur_invoke(pid t pid, int is high, int is critical, char *command); woon woonnom Create a new Process struct and initialize its members. wwwwww Note: For this function, you can assume pid, is high, and is critical are all valid values passed in.PID is also guaranteed to be unique for this process. Create a new Process Node (Otur process s) and initialize it with these values. 1. Set the Ready State bit of the state member to a 1. Only one of the three State flags should be set (1) at any given time. This means Running and Defunct bits should be Os. 2. Set the Critical bit of state to be 0 if is critical is false (0) or 1 if true. 3. Set the High bit of state to be 0 if is high is false (0) or 1 if true. Note, also set the High bit to 1 if is critical is true. Critical processes are always High Priority. 4. Set the lower 8-bits of state to be all Os. 5. Initialize age to 0. 6. Initialize the pid member to the pid argument. 7. Allocate memory (malloc) for the cmd member to be big enough for command. 8. String Copy (strncpy for safety!) command into your struct's cmd member. wwwwww 9. Initialize the next member to NULL. Return a pointer to your new process. Return a pointer to the process on success, or NULL on any errors.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Algorithms questions

Question

Describe corporate spying and reverse engineering.

Answered: 1 week ago

Question

=+c) Calculate the lower control limit of the p chart.

Answered: 1 week ago