BCA / B.Tech 12 min read

System Calls in Hindi

RK

लेखक Ratan Kumawat · संस्थापक, NotesMedia

प्रकाशित:

त्वरित सारांश और मुख्य बिंदु

  • • विषय फोकस: Operating System (OS) Notes in Hindi | ऑपरेटिंग सिस्टम नोट्स (BCA / B.Tech Syllabus)
  • • मुख्य विषय: System Calls in Hindi - General Topics
  • • अवलोकन: Quick Answer: Operating system में System Call एक programmatic interface है जिससे user program, OS के kernel से hardware resources और privileged servic...
  • • मुख्य अवधारणाएं: System calls, Types API process control Hindi, File manipulation calls,System calls, Types API process control, File manipulation calls
Quick Answer: Operating system में System Call एक programmatic interface है जिससे user program, OS के kernel से hardware resources और privileged services (जैसे file read/write करना, process बनाना, memory allocate करना) की request करता है। User applications सीधे hardware access नहीं कर सकते; इसलिए program trap (software interrupt) से user mode से kernel mode में switch करता है। Linux में fork(), open(), read() और Windows में CreateProcess(), CreateFile() इसके मुख्य examples हैं।

System Call in Operating System in Hindi क्या है?

जब आप C language में printf("Hello"); चलाते हैं या कोई file save करते हैं, तो screen पर text दिखाना या hard disk में data write करना user program सीधे नहीं कर सकता। Hardware (RAM, disk, printer, CPU) को सिर्फ operating system का kernel control करता है।

अगर हर program को सीधे hardware चलाने की छूट मिले, तो कोई भी गलत program पूरे system को crash कर सकता है। इसलिए OS दो separate modes में काम करता है:

  • User Mode: इसमें normal applications (जैसे browser, C program, media player) चलते हैं। इनके पास limited rights होते हैं और ये direct hardware access नहीं कर सकते।
  • Kernel Mode (Privileged Mode): इसमें OS का core kernel चलता है। इसके पास hardware instructions execute करने और system resources access करने की पूरी power होती है।

जब user program को किसी hardware resource की ज़रूरत होती है, तो वह kernel से request करता है। इसी request mechanism को System Call कहते हैं।

Real-world Example: इसे bank के cash counter से समझें। Bank customer (User Program) सीधे bank के cash vault (Hardware) में जाकर पैसे नहीं निकाल सकता। उसे counter पर बैठे cashier (System Call Interface) को cheque देना होता है। Cashier verify करके vault से cash निकाल कर देता है। Kernel का architecture detail में यहाँ समझें: Kernel Based Operating System in Hindi.

Advertisement

System Call कैसे काम करता है? (Dual Mode और Architecture)

CPU hardware में एक Mode Bit होता है। जब mode bit की value 1 होती है, तो CPU User Mode में होता है। जब mode bit 0 होता है, तो CPU Kernel Mode में होता है।

System call का execution flow नीचे दिए गए steps में होता है:

  1. Application Call: User program library function (जैसे C का read()) call करता है।
  2. Parameter Passing: Program parameters और unique system call number को CPU registers या stack में रखता है।
  3. Trap Instruction: CPU एक special software interrupt execute करता है जिसे trap कहते हैं। इससे hardware mode bit 1 से बदलकर 0 (kernel mode) हो जाता है।
  4. System Call Table Lookup: Kernel अपनी lookup table (sys_call_table) से number match करके interrupt service routine चलाता है।
  5. Hardware Access: Kernel device driver से data read या write करता है।
  6. Return to User Mode: काम पूरा होने पर result buffer में रखकर mode bit को वापस 0 से 1 कर दिया जाता है, और program user mode में लौट आता है।
+-------------------------------------------------------------+
|                        USER SPACE                           |
|  User Program  ---> Library Call (e.g. read())              |
|                             |                               |
|                             v                               |
|                     Trap / System Call                      |
+-----------------------------|-------------------------------+
                              | Mode Bit: 1 -> 0
+-----------------------------v-------------------------------+
|                       KERNEL SPACE                          |
|  System Call Table [sys_call_table]                         |
|                             |                               |
|                             v                               |
|  Kernel Service Routine (e.g. sys_read())                   |
|                             |                               |
|                             v                               |
|  Hardware / Device Driver (Disk Controller)                 |
|                             |                               |
|                             v                               |
|  Return from Trap (Mode Bit: 0 -> 1)                        |
+-------------------------------------------------------------+

Types of System Calls in OS in Hindi

Operating system में system calls को मुख्य 6 categories में बांटा जाता है। नीचे दी गई table में Linux और Windows के calls की तुलना देखें:

Category क्या काम करता है Linux / Unix Calls Windows Calls
1. Process Control Process बनाना, terminate करना, wait करना, load करना fork(), exec(), exit(), wait() CreateProcess(), ExitProcess(), WaitForSingleObject()
2. File Management File create, open, read, write, close और delete करना open(), read(), write(), close() CreateFile(), ReadFile(), WriteFile(), CloseHandle()
3. Device Management Hardware devices को control, read और write करना ioctl(), read(), write() SetConsoleMode(), ReadConsole(), WriteConsole()
4. Information Maintenance System date, time, process ID और metadata access करना getpid(), alarm(), sleep(), time() GetCurrentProcessId(), SetTimer(), Sleep()
5. Communication Processes के बीच data exchange और network packets भेजना pipe(), shmget(), send(), recv() CreatePipe(), CreateFileMapping(), MapViewOfFile()
6. Protection File permissions और access rights set करना chmod(), umask(), chown() SetFileSecurity(), GetFileSecurity()

1. Process Control

नए process को memory में load और run करने के लिए calls:

  • fork(): Running process का clone बनाकर नया child process create करता है।
  • exec(): Current process memory में नया program binary load करके execute करता है।
  • wait(): Parent process को child process finish होने तक रोक कर रखता है।
  • exit(): Process का execution stop करके resources release करता है।

2. File Management

Files open करने, data read/write करने और directory handle करने के लिए calls काम आती हैं। Linux file system की details: File System in Linux in Hindi.

  • open(): File को path से open करके integer file descriptor return करता है।
  • read(): Open file से data buffer memory में transfer करता है।
  • write(): Memory buffer से data निकालकर file में save करता है।
  • close(): File descriptor को free करता है।

3. Device Management

Terminal, disk controller और serial devices को manage करने के लिए ioctl() (I/O Control), read() और write() इस्तेमाल होते हैं।

4. Information Maintenance

System state जानने के लिए OS calls:

  • getpid(): Current process की unique Process ID return करता है।
  • time(): Current epoch time (seconds) return करता है।
  • sleep(): Process को specified seconds के लिए pause करता है।

5. Communication (IPC)

Processes आपस में message passing (जैसे pipe(), send(), recv()) या shared memory (shmget()) से data exchange करते हैं। IPC detail: Inter Process Communication in Hindi.

6. Protection

Files और resources को unauthorized users से सुरक्षित रखने के लिए chmod() (file permission change) और chown() (owner change) use होते हैं। OS goals guide: Goals of Operating System in Hindi.

User Mode vs Kernel Mode

System call execution में User Mode और Kernel Mode का अंतर सबसे critical topic है:

Feature User Mode Kernel Mode
Mode Bit Value 1 0
Privilege Level Low privilege (Ring 3) High privilege / Supervisor (Ring 0)
Hardware Access सीधे hardware access नहीं कर सकता CPU, RAM, Disks और Devices का direct access होता है
System Crash Impact Crash होने पर सिर्फ वही process बंद होता है; OS सुरक्षित रहता है Crash होने पर पूरा computer crash (Kernel Panic / BSOD) हो जाता है
Switching Method Trap या software interrupt से kernel mode में जाता है Return instruction से वापस user mode में आता है

System Call vs Library Function

Feature System Call (e.g. write()) Library Function (e.g. printf())
Execution Space Kernel Space में run होता है User Space में run होता है
Speed / Overhead धीमा होता है क्योंकि CPU mode switch का overhead लगता है तेज़ होता है; mode switch की ज़रूरत नहीं पड़ती
Portability Platform-dependent (Linux calls Windows पर सीधे नहीं चलतीं) Platform-independent (C standard library हर OS पर available है)
Internal Connection Core OS interface है अक्सर internally system call को wrap करता है (printf internally write() call करता है)

Worked Example 1: File Copy का Step-by-Step System Call Trace

मान लें एक program source.txt से 20 bytes read करके dest.txt में copy करता है। OS level पर यह sequence इस तरह चलता है:

Step System Call & Arguments CPU Mode Action / Return Value
1 open("source.txt", O_RDONLY) User -> Kernel -> User File open हुई; File Descriptor fd_in = 3 मिला
2 open("dest.txt", O_WRONLY|O_CREAT, 0644) User -> Kernel -> User Target file create हुई; fd_out = 4 मिला
3 read(fd_in, buffer, 20) User -> Kernel -> User Disk से 20 bytes buffer में load हुए; return 20
4 write(fd_out, buffer, 20) User -> Kernel -> User Buffer से 20 bytes disk block में save हुए; return 20
5 read(fd_in, buffer, 20) User -> Kernel -> User End-of-File (EOF) detect हुआ; return 0
6 close(fd_in) और close(fd_out) User -> Kernel -> User Descriptors 3 और 4 free कर दिए गए; return 0
7 exit(0) User -> Kernel Process clean up हुआ, memory free हुई
Advertisement

Worked Example 2: Linux में fork() System Call का C Program

नीचे दिया गया program fork() call से child process create करता है:

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main() {
    pid_t pid;

    // fork() system call invoke होती है
    pid = fork();

    if (pid < 0) {
        printf("System call failed\n");
        return 1;
    } else if (pid == 0) {
        // Child Process
        printf("Child Process: PID = %d, Parent PID = %d\n", getpid(), getppid());
    } else {
        // Parent Process
        printf("Parent Process: PID = %d, Child created with PID = %d\n", getpid(), pid);
    }

    return 0;
}

Actual Output:

Parent Process: PID = 2410, Child created with PID = 2411
Child Process: PID = 2411, Parent PID = 2410

Key Concept: fork() एक बार call होता है और दो बार return करता है। Parent को child की PID (2411) और child को 0 return मिलता है।

Exam में कैसे लिखें (5 Marks का Ready Answer)

University exam (BCA/B.Tech/MDSU/RTU) में 5 marks के लिए उत्तर इस point format में लिखें:

  1. Definition: System call user application और OS kernel के बीच का programmatic interface है जो hardware access और system services देता है।
  2. Dual Mode: CPU दो modes में काम करता है: User Mode (Mode Bit = 1, restricted access) और Kernel Mode (Mode Bit = 0, full hardware access)।
  3. Trap Mechanism: Program trap instruction execute करता है, जिससे CPU mode bit 1 से 0 में switch होता है।
  4. 5 Categories: Process Control (fork), File Management (open), Device Management (ioctl), Information Maintenance (getpid), Communication (pipe)।
  5. Flow Diagram: User Space (Call -> Trap) -> Kernel Space (Table Lookup -> Service Routine) -> Return to User Mode.
  6. Return Value: Success पर 0 या positive descriptor/PID मिलता है; failure पर -1 return होता है और error code errno में store होता है।

Advantages और Disadvantages of System Calls

Advantages Disadvantages / Overhead
Hardware Protection: Programs direct memory या disk overwrite नहीं कर सकते; crash रुकता है। Performance Overhead: User Mode से Kernel Mode में switch होने से CPU cycles खर्च होते हैं।
Resource Sharing: कई processes एक साथ printer या storage safe तरीके से share करते हैं। Portability Issue: Linux और Windows की calls अलग होती हैं, इसलिए code directly portable नहीं होता।
Abstraction: Programmer को disk sectors याद रखने की ज़रूरत नहीं; सिर्फ read() या write() call करना होता है। Complex Error Handling: Return values और low-level error codes को manual handle करना पड़ता है।

Students की Common Mistakes (सावधानियाँ)

  • 1. printf() को direct system call मानना: printf() C library function है। यह user space buffer use करता है और data screen पर भेजने के लिए internally write() system call को trigger करता है।
  • 2. System call को user mode में run होते समझना: System call user mode से invoke होती है, लेकिन उसका actual code kernel mode में ही execute होता है।
  • 3. Return value check न करना: open() या fork() fail होने पर -1 return करते हैं। अगर return value check किए बिना code आगे बढ़ेगा, तो segmentation fault आ जाता है।
  • 4. Mode Switch और Context Switch को एक समझना: System call में सिर्फ mode switch (User to Kernel) होता है, जो fast है। Process context switch में एक process की state save करके दूसरे process को CPU दिया जाता है।

Exam के लिए Important Questions

Short Questions (2–3 marks)

  1. System Call क्या है? (User program और kernel के बीच hardware access देने वाला programmatic interface)
  2. Trap (Software Interrupt) क्या होता है? (Instruction जो CPU mode bit को 1 से 0 में switch करके control kernel को देती है)
  3. Mode Bit का क्या काम है? (यह CPU mode track करता है: 1 = User mode, 0 = Kernel mode)
  4. Linux में process creation और termination के लिए system calls बताइए। (fork() और exit())
  5. System Call fail होने पर क्या return होता है? (आमतौर पर -1 return होता है और error detail errno variable में जाती है)

Long Questions (5–10 marks)

  1. System Call in Operating System क्या है? Dual-mode operation और system call execution steps को diagram के साथ समझाइए।
  2. System Calls के मुख्य types कौनसे हैं? Linux और Windows के examples के साथ detail में तुलना कीजिए।
  3. System Call और Library Function में अंतर स्पष्ट कीजिए। File copy operation का step-by-step trace लिखिए।

FAQs

System call in operating system in hindi का सबसे आसान मतलब क्या है?

इसका मतलब है user software का OS kernel से मदद मांगना। जब भी किसी app को screen पर text दिखाना हो, disk में file save करनी हो या internet packet भेजना हो, तो वह system call के ज़रिए ही OS से hardware use करने की permission लेता है।

User mode और Kernel mode में क्या अंतर होता है?

User mode limited privilege वाला mode है जहाँ normal applications चलते हैं ताकि system secure रहे। Kernel mode privileged mode है जहाँ OS का core system resources और hardware instructions को बिना किसी रोक-टोक के execute करता है।

fork() system call क्या return करती है?

fork() child process को 0 return करती है और parent process को new child की Process ID (PID) return करती है। Fail होने पर यह -1 return करती है।

Programmer system call सीधे call क्यों नहीं करते, API क्यों use करते हैं?

Direct system call लिखना complex और platform-dependent होता है। Windows API या POSIX API आसान wrapper functions देते हैं, जिससे code हर machine पर portable रहता है।

Trap और Hardware Interrupt में क्या अंतर है?

Hardware interrupt बाहरी devices (जैसे keyboard press या mouse move) से asynchronous तरीके से generate होता है। Trap एक software-generated synchronous interrupt है जो user program के अंदर instruction (जैसे system call या divide by zero) execute होने पर उठता है।

अक्सर पूछे जाने वाले प्रश्न (FAQs)

Quick Answer: Operating system में System Call एक programmatic interface है जिससे user program, OS के kernel से hardware resources और privileged services (जैसे file read/write करना, process बनाना, memory allocate करना) की request करता है।
Operating System (OS) Notes in Hindi | ऑपरेटिंग सिस्टम नोट्स के पाठ्यक्रम में System Calls in Hindi एक महत्वपूर्ण अध्याय है। यह मुख्य सिद्धांतों, परीक्षा प्रश्नों और सूत्रों को समझने के लिए अत्यधिक आवश्यक है।
हाँ, NotesMedia पर आपको System Calls in Hindi के महत्वपूर्ण प्रश्नोत्तर, हल किए गए उदाहरण और नोट्स बिल्कुल मुफ्त मिलेंगे। अधिक अभ्यास के लिए आप हमारा ऐप भी डाउनलोड कर सकते हैं।
Advertisement

In this Chapter

System Calls in Hindi
Distributed System in Hindi
Real Time System in Hindi
System Program in Hindi
Structure of Operating System in Hindi
Layers Design of Structure in Hindi
Unix in Hindi
Virtual Machine in Hindi
Kernel-Based Operating System in Hindi
Process in Hindi – OS में Process क्या है
Interacting Processes in Hindi
Threads in Hindi
Fundamental of Schedulling in Hindi
Scheduling Criteria in Hindi
Long Medium Short Term Scheduling in Hindi
Scheduling Algorithms in Hindi
Structure of Concurrent System in Hindi
Critical Region in Hindi
Critical Section in Hindi
Inter process Communication in Hindi
Monitor in Hindi
Semaphore in OS in Hindi – Counting और Binary Semaphore
Semaphores Implementation & Uses in Hindi
Logical and Physical Address in Hindi
Swapping in Hindi
Contiguous Allocation in Hindi
Segmentation in Hindi
Paging in OS in Hindi – Paging और Segmentation
Paging with Segmentation in Hindi
kernel Memory Allocation in Hindi
Page Replacement Algorithms in Hindi
Virtual Memory in Hindi
Virtual Memory with demand Paging in Hindi
Deadlock & Characterization in Hindi
Methods for Handling Deadlocks in Hindi
Deadlock Thrashing in Hindi
Allocation of Frames in Hindi
Virtual Memory using Segmentation in Hindi
Interprocess Communication protocol in Hindi
Network Operating System in Hindi
Design Issues in Distributed File System in Hindi
Network Structure in Hindi
Structure Distributed System in Hindi
File System and Coordination in Hindi
Linux in Hindi
Commands of Linux in Hindi | लिनक्स के कमांड्स हिंदी में
Programmer Interface & File manipulation in Hindi
Process control in Linux in Hindi
Linux Kernel & Signals in Hindi
File System in Linux in Hindi
block & inodes in Hindi
System Editor in Hindi
Character Transliteration in Hindi
ED in Hindi
Vi Editor & There Commands in Hindi
Shell Script in Hindi
Looping & Decision Making in Hindi
Variables & File name Expansion in Hindi
Array in Hindi OS
Sub Program in Hindi
C interface with Linux in Hindi
Simpel Shell Programs in Hindi
BCA Part-1 | Operating Systems | Semester-I | MDSU Exam Paper 2023 (Held in 2024)
What is Operating System (OS) in Hindi
Operating System (OS) All Important Questions and Answers in Hindi (MDSU)
BCA || Operating System 2025 Paper || MDSU Exam Paper
BCA | OS(Operating System) 2023 Paper | MDSU Exam Paper
Type of Operating System in Hindi
Goals of Operating System in Hindi
Operation of Operating system in Hindi
Resource Allocation & Functions in Hindi
class of Operating system in Hindi
Batch Processing in Hindi
Multi Processing in Hindi
Time Sharing in Hindi