OS resource management and processes
הוצג
13:59
משאבים, קומפילרים ו-RPN
פתח דפדפן, נגן מוזיקה ומשחק. יש לך מעבד אחד — אולי כמה ליבות — אך כולם נראים כאילו רצים בו-זמנית. יחד הם שואפים ליותר…
קריינות באנגלית · כתוביות באנגלית ובסינית 中文 שאפשר להחליף ביניהן
בשיעור הזה
| English | משמעות |
|---|---|
| mouse pointer | A symbol on the screen that shows where the mouse is pointing. |
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| process/ˈprəʊses/ | תהליך |
| scheduler/ˈʃedjʊlə/ | מזמן |
| processor/ˈprəʊsesə/ | The component that executes instructions and performs the operations of a computer or similar system. |
| memory/ˈmeməri/ | The part of a computer that holds data and programs currently in use. |
| queue/kjuː/ | A data structure in which items are normally removed in the order they were added. |
| Multi-tasking/ˈmʌlti ˈtæskɪŋ/ | The processor is switched rapidly between processes, so several appear to run at once even though only one is executing at any instant. |
| Paging/ˈpeɪdʒɪŋ/ | Memory is moved between RAM and disk so more programs can be open than physical memory allows. |
| RAM/ræm/ | Random-access memory used for working data and instructions, usually losing its contents when power is removed. |
| disk/dɪsk/ | A storage device that holds programs and data even when power is off. |
| physical memory | The actual memory hardware that holds data and programs currently in use. |
| Spooling/ˈspuːlɪŋ/ | Output for a slow device is queued on disk, so the processor never waits for a printer. Caching keeps recently used data in fast memory so it need not be fetched again. |
| Caching/ˈkæʃɪŋ/ | The process of keeping recently used data in fast memory for quicker access. |
| user interface/ˈjuːzə ˈɪntəfeɪs/ | The controls, displays and interaction mechanisms through which a person communicates with a computer system or program. |
| command line | A place where users type text commands to interact with a computer. |
| GUI | A user interface that lets people interact using visual elements. |
| ready/ˈredi/ | Describes a process that can run and is waiting for the processor. |
| Round robin/raʊnd ˈrɒbɪn/ | A scheduling method that gives each ready process a fixed time slice in turn. |
| time slice/taɪm slaɪs/ | A short interval of processor time allocated to a task before another task may run. |
| first come first served | A scheduling method that runs processes in the order they become ready. |
| shortest job first | A scheduling method that selects the ready process with the shortest expected running time. |
| shortest remaining time | A scheduling method that selects the process with the least expected time left to run. |
| New | Being created. Ready: able to run, waiting only for the processor. Running: currently executing. Blocked : waiting for something else, usually input or output. Terminated : finished. |
| Blocked/blɒkt/ | Describes a process that cannot continue until an event occurs. |
| Terminated | Describes a process that has finished running or has been stopped. |
| I/O | The transfer of data into or out of a computer or process. |
| ready queue | A list of processes waiting for the processor so they can run. |
| context switch/ˈkɒntekst swɪtʃ/ | החלפת הקשר |
| registers/ˈredʒɪstəz/ | A small, fast storage location within a processor used to hold data, addresses or instructions temporarily. |
| program counter/ˈprəʊɡræm ˈkaʊntə/ | A register that holds the address of the next instruction to be fetched. |
| process control block/ˈprəʊses kənˈtrəʊl blɒk/ | בלוק בקרת תהליך |
| interrupts/ˈɪntərʌpts/ | Signals or events that cause normal processor execution to be suspended while service routines handle them. |
| kernel/ˈkɜːnl/ | The central part of an operating system that manages resources and provides core services to programs. |
| core/kɔː/ | The central or most important part of a system or region. |
| timer interrupt | A signal from a timer that returns control to the operating system. |
| pre-emptive scheduling | A method where the operating system can stop a running process and give another process time on the processor. |
מדוע העכבן עדיין נע כשהכל קפא
- תוכנית נתקעת. החלון לא יתחדש, הספינר יפסיק, כלום לא מגיב. עם זאת, חיצן העכבן עדיין מחליק על המסך בדיוק כמו לפני כן.
- זה אומר שהמערכת הפעילה מעבירה הודעה: המכונה לא נתקעה, אלא תהליך אחד כן. המתזמן עדיין מחלק פרוסות מעבד, והתוכנית הקפואה פשוט אינה עושה שימוש מועיל בפרוסות שלה.
- כל המשאבים במכונה משותפים כך: המעבד בזמן, הזיכרון במרחב, ההדפסן בתור.
- שיעור זה מראה כיצד מערכת הפעלה מקבלת את המקסימום ממשאבים אלו, וכיצד היא מנהלת תהליך מיצירה ועד לסיום.

לקחת את המקסימום ממשאבים
- רב-ריצות: המעבד מוחלף במהירות בין תהליכים, כך שרבים נראים כאילו רצים בו-זמנית, למרות שרק אחד מתבצע בכל רגע נתון.
- דפייה: זיכרון מועבר בין RAM לבין דיסק כדי לאפשר פתיחה של יותר תוכניות מאשר הזיכרון הפיזי מאפשר.
- הקצאה (Spooling): פלט למכטה איטית מוקץ בדיסק, כך שהמעבד לעולם לא מחכה להדפסן. מטמון (Caching) שומר נתונים שהשתמשנו בהם לאחרונה בזיכרון מהיר כך שלא יהיה צורך למשוך אותם שוב.
- מערכת הפעלה גם מסתרת את כל זה מאחורי ממשק משתמש, קו פקודות או GUI.

Multi-tasking lets several programs appear to run at once by:
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
The OS rapidly switches the single CPU between processes so they all seem to progress together.
דוגמה מופתרת: מדוע הקצאה עוזרת
- הסבר כיצד הקצאה משפרת את השימוש במשאבי המחשב. [3]
- הדפסה היא אלפי פעמים איטית מהמעבד, ולכן תוכנית ששולחת פלט ישירות תחכה עליו והמעבד ישבת בלתי פעיל.
- עם ספולिंग, הפלט נכתב במהירות לתור על הכונן, והתוכנית ממשיכה מיד.
- תהליך נפרד מזין את המדפסת בקצבו העצמי, ומספר משימות יכולות לעמוד בתור בעוד מעבד עוסק בעבודה אחרת. ציין את ההתקן האיטי, את התור ומה שמעבד עושה במקום זאת.

Spooling helps the system because:
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
Spooling buffers print jobs to disk so the fast CPU is not held up by the slow printer.
Which techniques help an OS get the most from its resources? Select כולם that apply.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
Sharing time, queueing for slow devices and keeping hot data close. Killing waiting processes would lose the user's work, not improve utilisation.
תהליכים ומתכנן
- תהליך הוא תוכנית בביצוע: הקוד שלה, מצבה הנוכחי, הזיכרון והקובצים הפתוחים בה. תוכנית בכונן אינה תהליך; תוכנית רצה היא.
- המתכנן מחליט איזה תהליך מוכן ירצה הבא וכמה זמן. המטרות שלו הן לשמור על מעבד עסוק, להגיב במהירות למשתמשים אינטראקטיביים ולהיות הוגן.
- סיבובית (Round robin) מעניקה לכל תהליך מוכן חלוקת זמן קבועה ואז שולחת אותו לסוף התור: פשוטה, הוגנת ומגיבה. מדיניותות אחרות הן ראשון מגיע, ראשון משרת, קצר משימה תחילה וקצר זמן שנותר.

כולם מקבלים תור, ואף אחד לא אחזיק את המעבד

Round-robin scheduling gives each ready process a fixed time slice, then moves it to the back of the queue — making it fair and responsive.
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
Equal time slices in turn stop any one process hogging the CPU, so interactive programs stay responsive.
What is a process?
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
The file on disk is a program; once it is loaded and running, with state of its own, it is a process.
מצבי תהליך
- חדש: נוצר. מוכן: מסוגל לרץ, מחכה רק למעבד. רץ: מבצע כעת. חסום: מחכה לדבר אחר, בדרך כלל כניסה/יציאה. סופק: הסתיים.
- המעברים הם מה שהבחינה שואלת. מרץ למוכן כאשר חלוקת הזמן מסתיימת. מרץ לחסום כאשר התהליך מבקש I/O. מחסום למוכן כאשר ה-I/O נגמר. ממוכן לרץ כאשר המתכנן בוחר אותו.
- שים לב לחוסר הסימטריה: תהליך חסום לעולם לא חוזר ישירות לרץ. הוא מתחבר לתור המוכנים וממתין לתור שלו.

חמש מצבים, והסיבות לכל חץ

Match each process state to what it means.
רמת קושי 2/5 · 140 מטבעות + בונוס קטן בהשלמה הראשונה היום
A process cycles ready → running → (blocked) → ready, until it terminates.
דוגמה פתורה: עקוב אחר תהליך
- תהליך רץ כאשר הוא מבקש לקרוא קובץ. תאר מה שקורה לו.
- הוא עובר מרץ לחסום, משום שהוא לא יכול להמשיך עד שהנתונים יגיעו, והמתכנן מיידי מעניק את המעבד לתהליך מוכן אחר במקום לחכות.
- כאשר הכונן סיים, התהליך עובר מחסום למוכן. הוא לא ממשיך מיד; הוא מצטרף לתור המוכנים.
- מאוחר יותר המתכנן בוחר אותו, והוא עובר ממוכן לרץ, וממשיך בדיוק מהנקודה שבה עצר.
The life of a process
Tap round the loop a process travels. It only runs when the scheduler picks it; needing I/O sends it to blocked, and finishing its time slice sends it back to ready — round and round until it's done.
A running process asks to read a file. Put what happens to it in order.
רמת קושי 3/5 · 200 מטבעות + בונוס קטן בהשלמה הראשונה היום
A blocked process never returns straight to running: it rejoins the ready queue and waits its turn.
החלפת הקשר
- כדי לשנות את התהליך הרץ, מערכת ההפעלה שומרת את מצב התהליך הנוכחי, הרשמים, נגדן התוכנית והסטטוס שלהם, ב-בלוק הבקרה בתהליך, ולאחר מכן מטעין את מצב התהליך הבא מבלוק הבקרה שלו.
- זהו החלפת הקשר. יש לה עלות אמיתית: במהלכה המעבד עוסק בעבודות תחזוקה ולא בעבודה של המשתמש.
- לכן, חתיכת הזמן היא איזון. אם היא ארוכה מדי, תוכניות אינטראקטיביות מרגישות איטיות; ואם היא קצרה מדי, המכונה מבזבזת את זמנה בהחלפת הקשר במקום לחשב.

A context switch involves:
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
The OS saves the running process's registers/PC to its PCB and loads the next process's — a small overhead each switch.
During a context switch, a process's registers and program counter are saved into its ____.
רמת קושי 1/5 · 100 מטבעות + בונוס קטן בהשלמה הראשונה היום
The next process's state is then loaded from its own block. The saving and loading is real work, which is what makes switching cost time.
הפרעות והליבה
- ה-ליבה, ליבת מערכת ההפעלה, היא זו שמבצעת בפועל זאת: היא מגיבה להפרעות מכשירים ותוכניות, והפרעה היא מה שמחזיר שליטה למערכת ההפעלה מתהליך רץ.
- הפרעת טיימר בסוף חלון זמן היא מה הופך תכנון מקדע אפשרי בכלל; ללאה תוכנית שלא מעולם תתן את היחידה להשאר בה לתמיד.
- זוהי התשובה לפאזול הפתיחה: התוכנית הקפואה לא תופסת יותר ממעבד מחלקת הזמן שלה, ולכן העכבר ממשיך לנוע.
סימונים נופלים מהיד
- תהליך הוא תוכנית הנמצאת בביצוע, ולא הקובץ על הכונן.
- חסום למוכן, לעולם לא חסום ישירות לריצה. המתכנן בוחר מתי הוא ירץ שוב.
- החלפת הקשר שומרת ומשחזרת מצב דרך בלוק הבקרה בתהליך, והיא עולה בזמן.
- רב-משימהי (Multi-tasking) אומר שתהליכים לוקחים תור במהירות כזו שהם נראים מקבילים, ולא שאם הם באמת מבוצעים בו-זמנית על ליבה אחת.
הבנתך מושלמת
- מערכת ההפעלה מקסימה שימוש במשאבים על ידי רב-משימהי, חלוקה (paging), הזרקה (spooling) לתור דיסק ומטמון (caching)
- תהליך הוא תוכנית בביצוע; המתכנן בוחר את הבא ממוכן, כאשר סירוביות מעניקה לכל אחד חתיכת זמן קבועה
- מצבים: חדש, מוכן, רץ, חסום, מופסק: פתיחת חתיכת זמן שולחת רץ למוכן, בקשת I/O שולחת אותו לחסום, והשלמת I/O שולחת אותו חזרה למוכן
- החלפת הקשר שומרת ומשחזרת מצב דרך בלוק הבקרה בתהליך ועולה בזמן, ולכן אורך חתיכת הזמן הוא איזון
מה השתבש? רק צוות האתר רואה זאת.