Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please change the following code to python form. #include #include #define MIN_PID 300 #define MAX_PID 5000 #define TRUE 1 #define FALSE 0 struct PidTable{ int

Please change the following code to python form.

#include #include #define MIN_PID 300 #define MAX_PID 5000 #define TRUE 1 #define FALSE 0 struct PidTable{ int PID; int isAvailable; }*pId; int allocate_map(){ int i; pId=(struct PidTable *)calloc((MAX_PID-MIN_PID+1),sizeof(struct PidTable)); if(pId==NULL) return -1; pId[0].PID=MIN_PID; pId[0].isAvailable=TRUE; for( i=1;ireturn 1; } int allocate_pid(){ int i ; for( i=0;iif(pId[i].isAvailable==TRUE){ pId[i].isAvailable=FALSE; return pId[i].PID; } } if(i==MAX_PID-MIN_PID+1) return -1; } void release_pid(int pid){ pId[pid-MIN_PID].isAvailable=TRUE; } int main(){ int pid; allocate_map(); if((pid=allocate_pid())!=-1); printf("New Process Allocated Pid= %d  ",pid); if((pid=allocate_pid())!=-1); printf("New Process Allocated Pid= %d  ",pid); if((pid=allocate_pid())!=-1); printf("New Process Allocated Pid= %d  ",pid); if((pid=allocate_pid())!=-1); printf("New Process Allocated Pid= %d  ",pid); printf("Process %d now Releasing  ",pid); release_pid(pid); if((pid=allocate_pid())!=-1); printf("New Process Allocated Pid= %d  ",pid); return 0; }

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Describe the basic characteristics of inland marine floaters.

Answered: 1 week ago

Question

how would you have done things differently?

Answered: 1 week ago