What is fundamental difference between Process and Threads? How are the threads useful to establish concurrent socket communication? How do you perform secure communication using RSA? Explain with example.
10 marks
Question source
- Exam year
- 2080 BS / 2024 AD
- Level
- Sub-Inspector (Prabidhik – IT/Computer)
- Paper
- Paper II – Professional and Service Specific Test
- Section
- Section A
Model answer
Process vs Threads:
| Basis | Process | Thread |
|---|---|---|
| Meaning | Independent program in execution (own memory) | Lightweight unit inside a process (shares memory) |
| Memory | Separate address space | Shared code/data of parent process |
| Cost | Heavy to create/switch | Light, fast switch |
| Example | Word and Browser are two processes | Word's spell-check + typing are threads |
Threads for concurrent socket communication: A server must serve many clients at once. Single-threaded server handles one client, others wait. Multi-threaded server creates one thread per client socket — e.g. police record server: thread-1 handles Kathmandu query, thread-2 handles Surkhet query simultaneously on same port, sharing the database connection pool. Non-blocking I/O + thread pool prevents one slow client blocking others.
Secure communication with RSA (example): RSA is asymmetric: public key encrypts, private key decrypts.
- Receiver (server) generates key pair, shares public key openly, keeps private key secret.
- Sender encrypts message:
cipher = message^e mod nusing receiver's public key. - Only receiver decrypts with private key. Eavesdropper with only public key cannot reverse it feasibly.
Example: ASI exam server publishes public key; constable encrypts FIR text with it; only server's private key opens it. In practice RSA exchanges a session key, then fast AES encrypts bulk data (hybrid) with digital signature for authenticity.