📜  FINAL CODES_MY_OS_LAB - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:16.691000             🧑  作者: Mango

代码示例1
#include 
using namespace std;
struct sjrf
{
    int pid;
    int at;
    int bt;
    int tt;
    int wt;
}processes[10];
int n;

int totalBrust();
int Minimum(int max);
void sort(); // if user not enter processes value in sorted order w.r.t arival time
void Display()
{
    printf("%-15s\t%-15s\t%-15s\t%-15s\t%-15s\n","PID","Arival Time","Brust Time","Terminate Time","Waiting Time");
    for (int i = 0; i < n; ++i) {
        printf("%-15d\t%-15d\t%-15d\t%-15d\t%-15d\n",processes[i].pid,processes[i].at,processes[i].bt,processes[i].tt,processes[i].wt);
    }
}
int final;
int main() {
    cout<<"Enter number of processes : ";
    cin >>n;
    int temp[n];
    for (int i = 0; i < n; ++i) {
        processes[i].pid =i;
        cout<<"Enter Arival and brust tiem of process "<>processes[i].at>>processes[i].bt;
        temp[i] = processes[i].bt;
    }
    Display();
    int p=0;
    int current =0;
    final = totalBrust();
    for (int j = 0; j 
// using namespace std;
// struct Priority
// {
//     int pid;
//     int at;
//     int bt;
//     int pty;
//     int tt;
//     int wt;
// }processes[10];
// int n;

// int totalBrust();
// int Minimum(int max);
// void Display()
// {
//     printf("%-15s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s\n","PID","Arival Time","Brust Time","Priority","Terminate Time","Waiting Time");
//     for (int i = 0; i < n; ++i) {
//         printf("%-15d\t%-15d\t%-15d\t%-15d\t%-15d\t%-15d\n",processes[i].pid,processes[i].at,processes[i].bt,processes[i].pty,processes[i].tt,processes[i].wt);
//     }
// }
// int final;
// int main() {
//     cout<<"Enter number of processes : ";
//     cin >>n;
//     int temp[n];
//     for (int i = 0; i < n; ++i) {
//         processes[i].pid =i;
//         cout<<"Enter Arival Brust and priority of process "<>processes[i].at>>processes[i].bt>>processes[i].pty;
//         temp[i] = processes[i].bt;
//     }
//     Display();
//     int p=0;
//     int current =0;
//     final = totalBrust();
//     for (int j = 0; j