The Process Node (Otur_process_s) struct maintains their state using the state member. This 16-bit unsigned short...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. & ^ >> Description High State Flags Field Name H U RD Bit number 15 14 13 12 Crit Unused (All Os) C00 0 10 9 U = RUNNING STATE 11 Bit Numbers (Counting from the Right!) Hint: Look at the C Review on Bitwise Operations (Bit Masking) and Shifting! Hex: Exit Code Value (for Defunct Processes) exit_code 4 3 2 1 8 7 6 5 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) 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. When you set these bits, you can assume the Exit Code given to you will always fit without any overflow. Example: Process in the Defunct Queue, Defunct State, run as Critical, with exit_code of 6 1001 1000 0000 0110 Bin: 9 8 6 0 0 So, state = 0x9806 (Note: Remember Binary and Hex. Ox is the Hex prefix. Each hex digit is 4 bits in binary) yright 2024 Prof Kevin Mason University All Rights Resens Page 9/20 Otur_process_s *otur_invoke(pid_t pid, int is_high, int is_critical, char *command); Create a new Process struct and initialize its members. 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. o Set the Ready State bit of the state member to a 1. o o Only one of the three State flags should be set (1) at any given time. This means Running and Defunct bits should be Os. Set the Critical bit of state to be 0 if is_critical is false (0) or 1 if true. 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. o Set the lower 8-bits of state to be all Os. o Initialize age to 0. o Initialize the pid member to the pid argument. o Allocate memory (malloc) for the cmd member to be big enough for command. o String Copy (strncpy for safety!) command into your struct's cmd member. o 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. 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. & ^ >> Description High State Flags Field Name H U RD Bit number 15 14 13 12 Crit Unused (All Os) C00 0 10 9 U = RUNNING STATE 11 Bit Numbers (Counting from the Right!) Hint: Look at the C Review on Bitwise Operations (Bit Masking) and Shifting! Hex: Exit Code Value (for Defunct Processes) exit_code 4 3 2 1 8 7 6 5 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) 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. When you set these bits, you can assume the Exit Code given to you will always fit without any overflow. Example: Process in the Defunct Queue, Defunct State, run as Critical, with exit_code of 6 1001 1000 0000 0110 Bin: 9 8 6 0 0 So, state = 0x9806 (Note: Remember Binary and Hex. Ox is the Hex prefix. Each hex digit is 4 bits in binary) yright 2024 Prof Kevin Mason University All Rights Resens Page 9/20 Otur_process_s *otur_invoke(pid_t pid, int is_high, int is_critical, char *command); Create a new Process struct and initialize its members. 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. o Set the Ready State bit of the state member to a 1. o o Only one of the three State flags should be set (1) at any given time. This means Running and Defunct bits should be Os. Set the Critical bit of state to be 0 if is_critical is false (0) or 1 if true. 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. o Set the lower 8-bits of state to be all Os. o Initialize age to 0. o Initialize the pid member to the pid argument. o Allocate memory (malloc) for the cmd member to be big enough for command. o String Copy (strncpy for safety!) command into your struct's cmd member. o 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.
Expert Answer:
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date:
Students also viewed these algorithms questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
What is the charge of the iron ion released upon dissolvingFe(NH 4 ) 2 (SO 4 ) 2 ?Remember the charges of the polyatomic ions NH 4 andSO 4 and that the entire compound will be chargeneutral. a). 8+...
-
Apply the conservation of volume (see Prob. 1.9) to simulate the level of liquid in a conical storage tank (Fig. P1.11). The liquid flows in at a sinusoidal rate of Q in = 3 sin 2 (t) and flows out...
-
Explain the margin process, distinguishing between initial margin and maintenance margin. Who sets these margins?
-
What is transpiration? How does transpiration drive the movement of water up the xylem?
-
Transferred-in costs, FIFO method (continuation of 17-33). Refer to the information in Problem 17-33. Suppose that Larsen Company uses the FIFO method instead of the weighted-average method in all of...
-
1. Complete the chart and identify the directions of the following vectors using the reference angle, cardinal directions and the true north as point of references. S 64 R 30 a. Reference angle: J:...
-
Repeat Example 9.2, but with a feed pressure of 5.0 MPa. Compare your results to those obtained at a feed pressure of 1.0 \(\mathrm{MPa}\). Data From Example 9.2:- Air can be separated into...
-
Networks today span the globe. Hardware and software manufactured by different companies in different countries need to be interchangeable and able to work together. A network interface card needs to...
-
How do your workplace's policies and procedures align with requirements in your state/territory in relation to responding to children at risk?
-
Select a current social issue, then using a video about photojournalism select articles/items used by at least two mass communication formats to cover the issue (your example could include news and...
-
Hi Barbara, Look, we need to bring our costs down and our productivity up this quarter, and your department is one of the key areas where I'm looking to accomplish both goals. I've been noticing that...
-
How do you see role of physical inventory in future considering exponential growth in technology?
-
write a paragraph includes with these topics. Covid vaccination should be mandatory for all Canadians. Increases Safety 1. More protection + Example/ or explain the point increases immunity Reduce...
-
Check whether the operator T: R2 R? defined by T(x, y) = (y,x) is linear. Moreover if T is linear find T if exists.
-
5. Convert the following ERD to a relational model. SEATING RTABLE Seating ID Nbr of Guests Start TimeDate End TimeDate RTable Nbr RTable Nbr of Seats RTable Rating Uses EMPLOYEE Employee ID Emp...
-
The Woberg Company, located near Aarhus, Denmark, manufactured dishwashers and garbage pulverizers for home use, and cooking equipment and commercial pulverizers for restaurants. A relatively young...
-
What is e-business?
-
How can the international marketer overcome the incompatibility of research methods usable in different countries when doing a comparative study?
-
Using tha data file usmacro, estimate the ARDL \((2,1)\) model Your estimates should agree with the results given in equation (9.42). Use these estimates to verify the forecast results given in Table...
-
Using the data file usmacro, estimate the \(\operatorname{AR}(1)\) model \(G_{t}=\alpha+\phi G_{t-1}+v_{t}\). From these estimates and those obtained in Exercise 9.16, use the results from Exercise...
-
Consider the \(\operatorname{ARDL}(p, q)\) equation and the data in the file usmacro. For \(p=2\) and \(q=1\), results from the LM test for serially correlated errors were reported in Table 9.6 for...
Cost Accounting Processing Evaluating And Using Cost Data 2nd Edition - ISBN: 0201046776 - Free Book
Study smarter with the SolutionInn App