Loading...
Rupantarita Prakritik Gas Company Limited

Post: AGM (ICT)
Exam Date: 2022, Exam Taker: BUET
1. Write a C program: input: programming then taking input: gram Output: programming without having the gram from string
#include <stdio.h>
#include <string.h>

int main() {
    char str[100], word[20];
    int i, j, lw, pos = -1;

    // Taking input from user
    printf("Enter the main string: ");
    fgets(str, sizeof(str), stdin);

    printf("Enter the word to remove: ");
    fgets(word, sizeof(word), stdin);

    // Remove newline characters
    str[strcspn(str, "\n")] = '\0';
    word[strcspn(word, "\n")] = '\0';

    int ls = strlen(str);
    lw = strlen(word);

    // Find the word in the string
    for (i = 0; i <= ls - lw; i++) {
        for (j = 0; j < lw; j++) {
            if (str[i + j] != word[j])
                break;
        }
        if (j == lw) {
            pos = i;
            break;
        }
    }

    // Remove the word if found
    if (pos != -1) {
        for (i = pos; i < ls - lw; i++) {
            str[i] = str[i + lw];
        }
        str[ls - lw] = '\0';
    }

    printf("New String = %s\n", str);

    return 0;
}
    
        Sample I/O:
        Enter the main string: Programming
Enter the word to remove: gram
New String = Proming

=== Code Execution Successful ===
        


🔗 Run Online: Remove String

2. Wirte the Complexity best case, worst case: binary search, quick sort, DFS.
Algorithm NameWorst CaseAverage CaseBest Case
Binary SearchO(logn)O(logn)O(1)
Quick SortO(n^2)O(nlogn)O(nlogn)
DFSO(E+V)O(V+E)O(1)
3. What is Starvation in SJF? Write the name of Starvation free scheduling algorithm.

Starvation in SJF Scheduling
Starvation in Shortest Job First (SJF) scheduling occurs when a process with a long burst time waits indefinitely because the CPU always selects processes with shorter burst times. If short jobs keep arriving continuously, long jobs may never get CPU time, which leads to starvation.

Starvation-Free Scheduling Algorithm
A commonly used starvation-free scheduling algorithm is Round Robin (RR). In Round Robin scheduling, each process gets a fixed time quantum in a cyclic order, ensuring that no process waits forever.

SJF Scheduling এ Starvation
Shortest Job First (SJF) scheduling এ starvation ঘটে যখন কোনো process এর burst time বেশি হওয়ার কারণে সেটি দীর্ঘ সময় CPU পায় না। কারণ CPU সবসময় কম burst time যুক্ত process গুলোকে আগে execute করে। ফলে বারবার নতুন short job এলে long job গুলো অনির্দিষ্ট সময় অপেক্ষা করতে থাকে।

Starvation-Free Scheduling Algorithm
Starvation মুক্ত একটি scheduling algorithm হলো Round Robin (RR)। Round Robin এ প্রতিটি process নির্দিষ্ট time quantum পায়, ফলে কোনো process অনির্দিষ্ট সময় অপেক্ষা করে না।

4. Name four information stored in PCB.

Process Control Block (PCB)
A Process Control Block (PCB) is an important data structure used by the operating system to store all necessary information about a process. It helps the OS manage, control, and execute processes efficiently.

Main Information Stored in PCB
1) Process State: Shows the current state of the process such as new, ready, running, waiting, or terminated.
2) Process ID (PID): A unique number assigned to each process for identification.
3) Program Counter: Stores the address of the next instruction to be executed.
4) CPU Registers: Holds the contents of CPU registers so the process can resume correctly after interruption.

Additional Information Stored in PCB
Pointer: Links PCBs together and maintains parent-child relationships.
Memory Management Information: Contains page tables or segment tables related to the process memory.
Accounting Information: Keeps track of CPU time, execution time, and resource usage.
I/O Status: Stores information about allocated I/O devices.
Open Files List: Maintains a list of files currently opened by the process.
Process Privileges: Defines access rights and security permissions.
Scheduling Information: Includes priority, scheduling queue pointers, and other scheduling parameters.
Execution Context: Saves context information required during context switching.
Signals and Handlers: Manages signals sent to the process and their handling mechanisms.

Process Control Block (PCB)
Process Control Block (PCB) হলো operating system এর একটি গুরুত্বপূর্ণ data structure, যেখানে একটি process সম্পর্কিত সব তথ্য সংরক্ষণ করা হয়। এটি process পরিচালনা ও execution নিয়ন্ত্রণে সাহায্য করে।

PCB তে সংরক্ষিত প্রধান তথ্য
1) Process State: Process এর বর্তমান অবস্থা নির্দেশ করে, যেমন new, ready, running, waiting বা terminated।
2) Process ID (PID): প্রতিটি process এর জন্য নির্দিষ্ট একটি unique নম্বর।
3) Program Counter: পরবর্তী কোন instruction execute হবে তার address সংরক্ষণ করে।
4) CPU Registers: CPU register এর বর্তমান মান সংরক্ষণ করে যাতে process পুনরায় শুরু করা যায়।

PCB তে সংরক্ষিত অন্যান্য তথ্য
Pointer: বিভিন্ন PCB কে link করে এবং parent-child সম্পর্ক বজায় রাখে।
Memory Management Information: Process এর memory allocation সম্পর্কিত তথ্য (page table/segment table)।
Accounting Information: CPU usage ও resource ব্যবহারের হিসাব রাখে।
I/O Status: Process এর জন্য বরাদ্দকৃত I/O device এর তথ্য সংরক্ষণ করে।
Open Files List: Process দ্বারা খোলা ফাইলের তালিকা রাখে।
Process Privileges: Security ও resource access সংক্রান্ত অনুমতি নির্ধারণ করে।
Scheduling Information: Priority ও scheduling queue সম্পর্কিত তথ্য সংরক্ষণ করে।
Execution Context: Context switching এর সময় প্রয়োজনীয় তথ্য সংরক্ষণ করে।
Signals and Handlers: Process এ পাঠানো signal এবং তার handling ব্যবস্থা পরিচালনা করে।

You must subscribe & Login to view more.

Don’t have an account? Register

Or your subscription is under review by admin. Please message on WhatsApp / Telegram.

Leave a Comment

Latest Post
Field Based Job Question & Solution
Bank IT Job Solution

MCQ + Written from Bangladesh Bank, Sonali, Combined Bank IT recruitment.

BPSC IT Job Solution

BPSC Computer/IT cadre & non-cadre post Question papers with full solutions.

Gas Field IT Job Solution

Gas field like TGTDCL, BGDCL, JGTDSL, KGDCL, SGCL, RPGCL, GTCL etc. question solution

Power Sector IT Job Solution

Power sector such as NESCO, DESCO, DPDC, WZPDCL, BPDB, PGCB, BREB etc

Other IT Job Solution

Other Govt. Semi govt. organization like BCC, BTCL, CAAB, NSI etc.

NTRCA IT Job Solution (upcoming)

NTRCA ICT-related posts such as Assistant Teacher, Demonstrator, Lecturer.

IT MCQ Job Solution

Collected MCQ Job solution of BANK, BPSC, POWER SECTOR, GAS Field and Others.

Topic Based Q&S
WhatsApp Telegram Messenger