Answer to Question #174379 in C++ for Jean Claude

Question #174379

a) Discuss with 3 examples how kernel objects are represented in Windows and how the system programmer can manipulate these handle objects. AP,


b) Write a C/C++ system program to search for a file in the Windows file system and display the file information on the screen. Compile and run the program and copy the source code into your answer booklet.


c) Compare and contrast processes and threads and discuss how threads are scheduled.


1
Expert's answer
2021-03-27T00:16:36-0400

a) Kernel objects represented in window

Examples:

DosDevices represents Object directory.

\DosDevices\C: represents Device object representing the C: drive.

\DosDevices\C:\ represents Directory File object representing the directory named C:\Directory.

b) To search for a file in the Windows file system and display the file information on the screen

#include <iostream>

#include <fstream>

using namespace std;

int main()

{ string getcontent;

string search;

cout << "Input: ";

cin >> search;

ifstream openfile ("TEST.txt"); if(openfile.is_open())

{ while(!openfile.eof())

{

getline (openfile,getcontent);

if(search == getcontent )

{

cout << getcontent << endl;

}

} openfile.close();

} else

{

cout << "File error\n"; break;

}

system("PAUSE");

return 0;

}

c) Process means a program is in execution, whereas thread means a segment of a process.


A Process is not Lightweight, whereas Threads are Lightweight.


A Process takes more time to terminate, and the thread takes less time to terminate.


Process takes more time for creation, whereas Thread takes less time for creation.


Process likely takes more time for context switching whereas as Threads takes less time for context switching.

Thread is a basic unit of CPU utilization. It comprises of thread id, a program counter, a register set and a stack. It shares with other thread belonging to the same process it's code section, data section, and other operating system resources, such as open files and signals. If a process has a multiple thread of control, it can perform more than one task at a time

Different thread do different task. 

Considering the first thread take it locked mutex lock1 (so that other threads could not access the code) starts executing (code not added, just comments) and finally after completing its task waiting on cond1, likewise, the second thread locked mutex lock2, started executing its business logic, and, finally, waited on conditions from cond2 and the third thread locked mutex lock3, started executing its business logic and finally waited for the condition of cond3 and it continues. 



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS