النواة تهتم، أولاً وقبل كل شيء، بالتحكم بقطع العتاد، والتعرف عليها، تشغيلها عند تشغيل الحاسوب، وهكذا. كما أنها توفر واجهة برمجية مبسطة للعتاد تستفيد منها البرمجيات عالية المستوى، حتى تستثمر التطبيقات مزايا العتاد دون الحاجة للاهتمام بالتفاصيل مثل أي منفذ توسعة تم تركيب البطاقة الإضافية عليه. تُقدّم الواجهة البرمجية أيضًا طبقة عزل؛ تسمح هذه لبرمجيات الاجتماعات المرئية مثلاً، باستخدام كاميرا الوب بغض النظر عن الشركة الصانعة وطرازها. يستطيع البرنامج استخدام واجهة Video for Linux (V4L) ببساطة، وسوف تترجم النواة استدعاءات دوال هذه الواجهة إلى أوامر العتاد الفعلية التي تحتاجها كاميرا الوب الخاصة المستعملة.
تُصدِّر النواة العديد من التفاصيل عن العتاد الذي تعرفت عليه من خلال نظامي الملفات الوهميين
/proc/
و
/sys/
. تُلَخِّص العديد من الأدوات هذه التفاصيل. من بينها،
lspci
(في الحزمة
pciutils) التي تسرد أجهزة PCI، والأداة
lsusb
(في الحزمة
usbutils) التي تسرد أجهزة USB، وأيضًا
lspcmcia
(في الحزمة
pcmciautils) التي تسرد بطاقات PCMCIA. هذه الأدوات مفيدة جداً للتعرف على الطراز الدقيق للجهاز. بعد ذلك يمكن البحث في الوب بدقة أعلى، وبالتالي، الحصول على وثائق ذات صلة أكثر.
مثال B.1. مثال عن المعلومات التي يقدمها الأمر lspci
والأمر lsusb
$
lspci
[...]
00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 03)
00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 03)
[...]
01:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express (rev 01)
02:03.0 Network controller: Intel Corporation PRO/Wireless 2200BG Network Connection (rev 05)
$
lsusb
Bus 005 Device 004: ID 413c:a005 Dell Computer Corp.
Bus 005 Device 008: ID 413c:9001 Dell Computer Corp.
Bus 005 Device 007: ID 045e:00dd Microsoft Corp.
Bus 005 Device 006: ID 046d:c03d Logitech, Inc.
[...]
Bus 002 Device 004: ID 413c:8103 Dell Computer Corp. Wireless 350 Bluetooth
لهذه البرامج خيار -v
، الذي يعرض معلومات مفصلة أكثر بكثير (لكن غير ضرورية عادة). أخيراً، يسرد الأمر lsdev
(في الحزمة procinfo) موارد التواصل التي تستهلكها الأجهزة.
تصل التطبيقات إلى الأجهزة غالبًا عبر ملفات خاصة منشأة ضمن المجلد
/dev/
(انظر الملاحظة الجانبية
أساسيات صلاحيات الوصول للأجهزة). هذه الملفات هي ملفات خاصة تمثّل سواقات الأقراص الصلبة (مثلاً،
/dev/hda
و
/dev/sdc
)، أو أقسام الأقراص (مثلاً،
/dev/hda1
أو
/dev/sdc3
)، الفأرات (
/dev/input/mouse0
)، لوحات المفاتيح (
/dev/input/event0
)، بطاقات الصوت (
/dev/snd/*
)، المنافذ التسلسلية (
/dev/ttyS*
)، وغيرها.
نظم الملفات هي إحدى أهم مظاهر النواة. تدمج النظم المشابهة لنظام يونكس جميع أجهزة تخزين الملفات في شجرة واحدة، والتي تسمح للمستخدمين (والتطبيقات) بالوصول إلى البيانات ببساطة بمعرفة مكانها ضمن تلك الشجرة.
تدعى نقطة البداية لهذه الشجرة الهرمية بالجذر root، ويرمز لها بالرمز /
. يستطيع هذا المجلد أن يحوي مجلدات فرعية مسماة. مثلا، يدعى مجلد home
(البيت) المتفرع عن /
باسم /home/
. يمكن لهذا المجلد الفرعي، بدوره، أن يحوي مجلدات فرعية أخرى، وهكذا. يمكن لكل مجلد أيضًا أن يحوي ملفات، حيث يتم تخزين البيانات الفعلية. بالتالي، يشير الاسم /home/rmas/Desktop/hello.txt
إلى الملف المسمى hello.txt
المخزن في المجلد Desktop
المتفرع عن المجلد rmas
المتفرع عن المجلد home
الموجود في الجذر. تترجم النواة بين نظام التسمية هذا وبين نظام التخزين الفعلي الفيزيائي على القرص.
Unlike other systems, there is only one such hierarchy, and it can integrate data from several disks. One of these disks is used as the root, and the others are “mounted” on directories in the hierarchy (the Unix command is called mount
); these other disks are then available under these “mount points”. This allows storing users' home directories (traditionally stored within /home/
) on a second hard disk, which will contain the rhertzog
and rmas
directories. Once the disk is mounted on /home/
, these directories become accessible at their usual locations, and paths such as /home/rmas/Desktop/hello.txt
keep working.
There are many filesystem formats, corresponding to many ways of physically storing data on disks. The most widely known are ext2, ext3 and ext4, but others exist. For instance, vfat is the system that was historically used by DOS and Windows operating systems, which allows using hard disks under Debian as well as under Windows. In any case, a filesystem must be prepared on a disk before it can be mounted and this operation is known as “formatting”. Commands such as mkfs.ext3
(where mkfs
stands for MaKe FileSystem) handle formatting. These commands require, as a parameter, a device file representing the partition to be formatted (for instance, /dev/sda1
). This operation is destructive and should only be run once, except if one deliberately wishes to wipe a filesystem and start afresh.
There are also network filesystems, such as
NFS, where data is not stored on a local disk. Instead, data is transmitted through the network to a server that stores and retrieves them on demand. The filesystem abstraction shields users from having to care: files remain accessible in their usual hierarchical way.
نظرًا لوجود عدد من الوظائف (functions) المتشابهة التي تستخدمها جميع البرمجيات، فمن المنطق تجميعها في النواة. مثلاً، تسمح الإدارة المشتركة لنظام الملفات لأي تطبيق بفتح أي ملف عبر استخدام اسمه ببساطة، دون الحاجة للاهتمام بمكان تخزين الملف فيزيائيًا. يمكن أن يخزَّن الملف في عدة شرائح مختلفة على قرص صلب، أو ينقسم بين عدة أقراص، أو حتى يخزَّن على مخدم ملفات بعيد. تستخدم التطبيقات دوال التواصل المشتركة لتبادل البيانات بغض النظر عن طريقة نقلها. مثلاً، يمكن أن تُنقَل عبر أية تركيبة من الشبكات المحلية أو اللاسلكية، أو عبر خط الهاتف الثابت.
العملية هي نسخة فعالة من البرنامج. تحتاج كل عملية إلى ذاكرة لتخزين كُلٍّ من البرنامج نفسه والبيانات التي يعمل عليها. النواة مسؤولة عن إنشاء وتتبع العمليات. عند تشغيل برنامج، تخصص له النواة جزءًا من الذاكرة، ثم تُحمِّل الشفرة التنفيذية من نظام الملفات إليه، بعدها تبدأ تشغيل الشِّفرة. تحتفظ النواة بمعلومات عن هذه العملية، أكثر هذه المعلومات بيانًا للعيان هو رقم تعريف العملية الذي يعرف بالرمز pid (مُعرِّف العملية process identifier).
Unix-like kernels (including Linux), like most other modern operating systems, are capable of “multi-tasking”. In other words, they allow running many processes “at the same time”. There is actually only one running process at any one time, but the kernel cuts time into small slices and runs each process in turn. Since these time slices are very short (in the millisecond range), they create the illusion of processes running in parallel, although they are actually only active during some time intervals and idle the rest of the time. The kernel's job is to adjust its scheduling mechanisms to keep that illusion, while maximizing the global system performance. If the time slices are too long, the application may not appear as responsive as desired. Too short, and the system loses time switching tasks too frequently. These decisions can be tweaked with process priorities. High-priority processes will run for longer and with more frequent time slices than low-priority processes.
طبعاً، تسمح النواة بتشغيل أكثر من نسخة مستقلة من البرنامج نفسه. لكن كل واحدة منها تستطيع استخدام ذاكرتها وشرائحها الزمنية الخاصة فقط. وبذلك تبقى بياناتها مستقلة.