In: Computer Science
Ans C:
Difference b/w Processes and Threds are:
Processes:
1) A process is a program under execution i.e an active program.
2) Processes require more time for context switching as they are more heavy.
3) Processes are totally independent and don’t share memory.
4) Communication between processes requires more time than between threads.
5) If a process gets blocked, remaining processes can continue execution.
6) Processes require more resources than threads.
7) Individual processes are independent of each other.
Threads:
1) A thread is a lightweight process that can be managed independently by a scheduler.
2) Threads require less time for context switching as they are lighter than processes.
3) A thread may share some memory with its peer threads.
4) Communication between threads requires less time than between processes .
5) If a user level thread gets blocked, all of its peer threads also get blocked.
6) Threads generally need less resources than processes.
7) Threads are parts of a process and so are dependent.
How Threads are scheduled
Threads are scheduled for execution depending on their priority. Even though threads are executing inside the runtime, all threads are allocated processor time slices by the operating system. For each operating system, the specifics of the scheduling algorithm used to decide the order in which threads are executed differ.
Ans B
Program to move a file from one folder to another .
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
using namespace std;
int main()
{
char src[50],dest[50],cmd[100];
cout<<"\nENTER FULL PATH OF FILE TO BE MOVED : ";
gets(src);
cout<<"ENTER FULL PATH WHERE FILE IS TO BE MOVED : ";
gets(dest);
strcpy(cmd,"mv ");
strcat(cmd,src);
strcat(cmd," ");
strcat(cmd,dest);
system(cmd);
return 0;
}