OS PyramidTechnion 234123 · Operating Systemsbasics → exam
the pyramid
Stage 4 / 10 · Foundations

Kernel Modulessupporting

Kernel modules provide a mechanism to extend the operating system's functionality dynamically, without requiring a full kernel recompile. They are essential for device drivers and system customization, allowing code to be loaded and unloaded at runtime. Understanding their lifecycle (initialization, cleanup) and how they interact with the kernel is crucial for comprehending modern OS architecture, even if direct exam questions are rare.

Where to learn it

tutorialTutorial 4 · modules
59 slides
Start with slides 1, 2, 3, 4, 5

How to study it

  • Focus on the `module_init()` and `module_exit()` functions and their respective roles in a module's lifecycle.
  • Understand the difference between kernel space and user space, and how kernel modules operate exclusively in kernel space.
  • Review the basic structure of a simple kernel module and how it registers/unregisters with the kernel.

What the exam asks

Typical exam questions, if any, would likely test your understanding of why kernel modules are used, their basic structure, or the implications of loading/unloading them.

Exam subsections in this stage (15 parts across 3 questions)

OS-Spring2021-examBQ1core7 parts here

סקריפט וקריאות מערכת (Shell Script and System Calls)

  1. a· short_answer· 2 pts

    האם הסקריפט יסיים את ריצתו בהצלחה וללא שגיאות? כן / לא נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  2. b· short_answer· 2 pts

    כעת נסיר את שורות 1 ו- 2. האם כעת הסקריפט יסיים את ריצתו בהצלחה וללא שגיאות? כן / לא נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  3. c· short_answer· 2 pts

    האם הקוד יעבוד? כן / לא במידה ולא, הציעי תיקון של שורה אחת כך שהוא יעבוד. נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  4. e· mcq· 3 pts

    מה יהיה הפלט של השורה הנ"ל? הסבירי. a. מי ששותה רק מים יש לו הרבה סודות גבינה חינם יש רק במלכודת עכברים אל תרוצי כשיורים עלייך כי תמותי עייפה b. מי ששותה רק מים יש לו הרבה סודות אל תרוצי כשיורים עלייך כי תמותי עייפה גבינה חינם יש רק במלכודת עכברים c. אל תרוצי כשיורים עלייך כי תמותי עייפה מי ששותה רק מים יש לו הרבה סודות גבינה חינם יש רק במלכודת עכברים d. אל תרוצי כשיורים עלייך כי תמותי עייפה מי ששותה רק מים יש לו הרבה סודות גבינה חינם יש רק במלכודת עכברים e. f. אף תשובה אינה נכונה נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  5. f· mcq· 3 pts

    נועה רוצה להוסיף לדרייבר תמיכה בפעולת mute להתקן. דרך איזה file operation נכון לממש אותה? הסבירי. a. open b. release c. flush d. Other: נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  6. g· short_answer· 3 pts

    לאחר הפרידה, נועה רוצה להוסיף התקן נוסף שמפעיל פלייבק של שירי דיכאון. האם אפשרי להשתמש בהתקן ללא הוספת דרייבר חדש? כן / לא נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
  7. h· short_answer· 3 pts

    קבעי האם הטענה הבאה נכונה: מודול חייב להגדיר קובץ ב - dev/ שאיתו הוא יעבוד. במילים אחרות, לכל מודול טעון יש קובץ אחד (לפחות) ב- dev/ כן/לא נימוק:

    System call trap and kernel entryfork/exec address-space semanticslibc syscall wrapper caching pitfalls
OS-Winter2022-examCQ4core7 parts here

מודולים

  1. 1· short_answer· 2 pts

    (2 נק') מודולים מאפשרים להוסיף לגרעין לינוקס, בזמן ריצה, קטעי קוד חדשים שרצים בהרשאות משתמש. הטענה נכונה: כן / לא נימוק:

    libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
  2. 2· short_answer· 2 pts

    (2 נק') האם ניתן ליצור 2 קבצי device בעלי אותו minor number? הטענה נכונה: כן / לא נימוק:

    libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
  3. 3· short_answer· 3 pts

    (3 נק') מני 2 הבדלים בין התקן תווים להתקן בלוקים תשובה:

    libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
  4. 4· short_answer· 2 pts

    (2 נק') נתונות הפקודות הבאות: 1. cat /dev/zero 2. echo "hi" > /dev/null 3. echo "hi" > /dev/random 4. cat /dev/null הקיפי את כל הפקודות אשר יתקבל בהן EOF נימוק:

    libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
  5. 5· mcq· 3 pts

    (3 נק') המקרו MAJOR והמקרו MINOR מחזירים את המספר הראשי (major number) והמספר המשני (minor number) עבור התקן (device) מסוים. מהיכן הם שולפים אותם (כלומר איפה הם שמורים)? א. file descriptor של ההתקן ב. במבנה נתונים ייעודי של הגרעין (שהוא לא chrdevs) ג. בכניסות המתאימות במערך chrdevs ד. בתוך הinode של ההתקן. נימוק:

    Hard link vs symlink inode behavior
  6. 6· mcq· 4 pts

    (4 נק') נתאר את התרחיש הבא: יצרנו 2 מודולים עם אותו הקוד בדיוק, ורק שמות המודולים הם שונים. כעת נטען את 2 המודולים עם major numbers שונים: M1, M2. כעת, ניצור שני קבצי device: 1. /dev/a בעל major number ששווה ל M1 2. /dev/b בעל major number ששווה ל M2 כאשר תהליך יפתח את dev/b/ ויבצע פעולה שתגרור קריאה לioctl, איזו טענה נכונה? A. הנתונים לא מספקים מספיק מידע כדי לדעת איזה מבין המודולים יבצע את הפעולה- זה תלוי בין היתר גם minor number שלהם. B. המודול M1 יבצע את הקריאה ioctl C. המודול M2 יבצע את הקריאה ioctl D. שני המודולים יבצעו את הקריאה נימוק:

    libc syscall wrapper caching pitfallsHard link vs symlink inode behavior
  7. 7· mcq· 4 pts

    (4 נק') נסתכל על קטע הקוד הבא: 1. #define MOD_NAME "MY_MODULE" 2. int my_major = 0; struct file_operations my_fops = { .open = my_open, .release = my_release, .read = my_read, .write= my_write, .llseek= NULL, .ioctl= my_ioctl, .owner= OWNER, }; 3. my_major = register_chrdev(my_major, MOD_NAME, &my_fops); בהנחה שקיים מודול בשם "MY_MODULE", ושכל הפונקציות של my_fops ממומשות כראוי, אילו מהטענות הבאות נכונה? A. בסיום שורה 3 יירשם דרייבר עם MAJOR NUMBER ששווה ל- 0 B. רישום הדרייבר לא יתבצע מכיוון שלא העברנו את הMINOR NUBER כפרמטר C. בסיום שורה 3 יירשם דרייבר עם MAJOR NUMBER שהמערכת תקצה D. רישום הדרייבר לא יתבצע מכיוון שב my_fops הפונקציה llseek מצביעה על NULL נימוק:

    libc syscall wrapper caching pitfalls