Question: This needs to be written in C code thanks Memory is allocated for a given process when a user starts a program. The OS can


This needs to be written in C code thanks
Memory is allocated for a given process when a user starts a program. The OS can give each process a different amount of memory based on how big the executable file is. So requests to the OS are received from the user to allocate or to free memory. The OS services the request and gives the new process the memory requested according to 3 popular algorithms First fit: Satisfy the request with the first available free memory block that is large enough to accommodate the request. Best fit: Satisfy the request with the free memory block that is large enough to service the request and small enough that it has the smallest fragmented block. Worst fit: Satisfy the request with the free memory block that is large enough to service the request and creates the largest fragmented block. Consider the following input format NI 500 T7 N indicates the process (1) that is being created needs memory (500 bytes). The result of this operation is either successful (indicated by a memory address returned that references the new memory) or a failure (indicated by a NULL memory address returned). The T operation is terminating the process (process 7 in this case) and freeing the memory that was assigned to the process. You are to write a program (no pthreads! - YAY) that will simulate the memory allocations/frees of the operating system. Your program will read input from stdin and produce output on stdout. Each line will be one of the two forms above Your program will take total amount of memory in your system as a command line parameter -s #. You have to implement all 3 algorithms with a command line option - f", "-b", or "-w" to select which algorithm is used. Output generated includes the following (one of these messages for each line of input) . If an allocation fails Memory is allocated for a given process when a user starts a program. The OS can give each process a different amount of memory based on how big the executable file is. So requests to the OS are received from the user to allocate or to free memory. The OS services the request and gives the new process the memory requested according to 3 popular algorithms First fit: Satisfy the request with the first available free memory block that is large enough to accommodate the request. Best fit: Satisfy the request with the free memory block that is large enough to service the request and small enough that it has the smallest fragmented block. Worst fit: Satisfy the request with the free memory block that is large enough to service the request and creates the largest fragmented block. Consider the following input format NI 500 T7 N indicates the process (1) that is being created needs memory (500 bytes). The result of this operation is either successful (indicated by a memory address returned that references the new memory) or a failure (indicated by a NULL memory address returned). The T operation is terminating the process (process 7 in this case) and freeing the memory that was assigned to the process. You are to write a program (no pthreads! - YAY) that will simulate the memory allocations/frees of the operating system. Your program will read input from stdin and produce output on stdout. Each line will be one of the two forms above Your program will take total amount of memory in your system as a command line parameter -s #. You have to implement all 3 algorithms with a command line option - f", "-b", or "-w" to select which algorithm is used. Output generated includes the following (one of these messages for each line of input) . If an allocation fails
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
