دانلود کتاب Programming Embedded Systems in C and C ++
49,000 تومان
برنامه نویسی سیستم های جاسازی شده در C و C ++
| موضوع اصلی | برنامه نویسی |
|---|---|
| نوع کالا | کتاب الکترونیکی |
| ناشر | O’Reilly Media |
| تعداد صفحه | 122 |
| حجم فایل | 554 کیلوبایت |
| کد کتاب | 1565923545 |
| نوبت چاپ | 1 |
| نویسنده | Michael Barr |
|---|---|
| زبان | انگلیسی |
| فرمت | |
| سال انتشار | 1999 |
جدول کد تخفیف
| تعداد کتاب | درصد تخفیف | قیمت کتاب |
| 1 | بدون تخفیف | 25,000 تومان |
| 2 | 20 درصد | 20,000 تومان |
| 3 الی 5 | 25 درصد | 18,750 تومان |
| 6 الی 10 | 30 درصد | 17,500 تومان |
| 11 الی 20 | 35 درصد | 16,250 تومان |
| 21 الی 30 | 40 درصد | 15,000 تومان |
| 31 الی 40 | 45 درصد | 13,750 تومان |
| 41 الی 50 | 50 درصد | 12,500 تومان |
| 51 الی 70 | 55 درصد | 11,250 تومان |
| 71 الی 100 | 60 درصد | 10,000 تومان |
| 101 الی 150 | 65 درصد | 8,750 تومان |
| 151 الی 200 | 70 درصد | 7,500 تومان |
| 201 الی 300 | 75 درصد | 6,250 تومان |
| 301 الی 500 | 80 درصد | 5,000 تومان |
| 501 الی 1000 | 85 درصد | 3,750 تومان |
| 1001 الی 10000 | 90 درصد | 2,500 تومان |
ترجمه فارسی توضیحات (ترجمه ماشینی)
برنامه نویسی سیستم های جاسازی شده در C و C ++
حتی با وجود اینکه کتاب تقریباً در هر موضوعی که به آن پرداخته جزئیات کافی را ارائه نمی دهد، هنوز هم خواندن بسیار جالبی است. به عنوان مثال، پاراگراف زیر تمام آن چیزی است که در مورد سوئیچ زمینه صحبت شده است، مختصر و در عین حال الهام بخش، به همین دلیل من به آن 4 ستاره دادم.
8.2.3 سوئیچ زمینه
فرآیند واقعی تغییر از یک کار به کار دیگر، سوئیچ زمینه نامیده می شود. از آنجایی که زمینهها مختص پردازنده هستند، کدی که سوئیچ متن را پیادهسازی میکند نیز همینطور است. یعنی همیشه باید به زبان اسمبلی نوشته شود. به جای نشان دادن کد اسمبلی خاص 80×86 که در ADEOS استفاده کردم، روال سوئیچ زمینه را در یک شبه کد C مانند نشان خواهم داد:
خالی
contextSwitch(PContext pOldContext، PContext pNewContext)
{
if (saveContext(pOldContext))
{
//
// بازیابی متن جدید فقط در خروجی غیر صفر از saveContext().
//
restoreContext(pNewContext);
// این خط هرگز اجرا نمی شود!
}
// در عوض، کار بازیابی شده در این نقطه به اجرای خود ادامه می دهد.
}
روال contextSwitch در واقع توسط زمانبندی فراخوانی می شود که به نوبه خود از یکی از فراخوانی های سیستم عامل که وقفه ها را غیرفعال می کند فراخوانی می شود. بنابراین نیازی به غیرفعال کردن وقفه ها در اینجا نیست. علاوه بر این، از آنجایی که فراخوانی سیستم عاملی که زمانبندی را فراخوانی میکند به زبان سطح بالا نوشته شده است، اکثر رجیسترهای وظیفه در حال اجرا قبلاً در پشته محلی آن ذخیره شدهاند. این مقدار کاری را که باید توسط روتینهای saveContext و restoreContext انجام شود کاهش میدهد. آنها فقط باید نگران ذخیره نشانگر دستورالعمل، نشانگر پشته و پرچم ها باشند.
مشاهده رفتار واقعی contextSwitch در زمان اجرا به سادگی با نگاه کردن به کد قبلی دشوار است. اکثر توسعه دهندگان نرم افزار به صورت سریالی فکر می کنند، با این فرض که هر خط کد بلافاصله پس از خط قبلی اجرا می شود. با این حال، این کد در واقع دو بار به صورت شبه موازی اجرا می شود. هنگامی که یک وظیفه (وظیفه جدید) به حالت در حال اجرا تغییر می کند، وظیفه دیگر (وظیفه قدیمی) باید به طور همزمان به حالت آماده بازگردد. تصور کنید که وقتی کار جدید در داخل کد restoreContext بازیابی می شود چه چیزی می بیند. مهم نیست که کار جدید قبلاً چه کاری انجام می داد، همیشه در داخل کد saveContext بیدار می شود – زیرا در آنجا نشانگر دستورالعمل آن ذخیره می شد.
چگونه کار جدید میداند که برای اولین بار از saveContext خارج میشود (یعنی در مرحله خواب) یا بار دوم (در مرحله بیدار شدن از خواب)؟ قطعاً باید تفاوت را بداند، بنابراین من مجبور شدم saveContext را به روشی کمی یواشکی پیاده سازی کنم. SaveContext به جای ذخیره کردن نشانگر دستورالعمل فعلی، در واقع آدرسی را چند دستورالعمل پیش رو ذخیره می کند. به این ترتیب، هنگامی که زمینه ذخیره شده بازیابی می شود، اجرا از نقطه دیگری در روال saveContext ادامه می یابد. همچنین این امکان را برای saveContext فراهم میکند که مقادیر مختلفی را برگرداند: زمانی که کار به حالت خواب میرود، غیر صفر و زمانی که کار بیدار میشود، صفر است. روال contextSwitch از این مقدار بازگشتی برای تصمیم گیری در مورد فراخوانی restoreContext استفاده می کند. اگر contextSwitch این بررسی را انجام نمی داد، کد مرتبط با کار جدید هرگز اجرا نمی شد.
Even though the book does not render enough details in almost every topic it touched, it still manages to be an very interesting read. For example, the following paragraph is all it talked about context switch, concise yet inspiring, that’s why I gave it 4 stars.
8.2.3 Context Switch
The actual process of changing from one task to another is called a context switch. Because contexts are processor-specific, so is the code that implements the context switch. That means it must always be written in assembly language. Rather than show you the 80×86-specific assembly code that I used in ADEOS, I’ll show the context switch routine in a C-like pseudocode:
void
contextSwitch(PContext pOldContext, PContext pNewContext)
{
if (saveContext(pOldContext))
{
//
// Restore new context only on a nonzero exit from saveContext().
//
restoreContext(pNewContext);
// This line is never executed!
}
// Instead, the restored task continues to execute at this point.
}
The contextSwitch routine is actually invoked by the scheduler, which is in turn called from one of the operating system calls that disables interrupts. So it is not necessary to disable interrupts here. In addition, because the operating system call that invoked the scheduler is written in a high-level language, most of the running task’s registers have already been saved onto its local stack. That reduces the amount of work that needs to be done by the routines saveContext and restoreContext. They need only worry about saving the instruction pointer, stack pointer, and flags.
The actual behavior of contextSwitch at runtime is difficult to see simply by looking at the previous code. Most software developers think serially, assuming that each line of code will be executed immediately following the previous one. However, this code is actually executed two times, in pseudoparallel. When one task (the new task) changes to the running state, another (the old task) must simultaneously go back to the ready state. Imagine what the new task sees when it is restored inside the restoreContext code. No matter what the new task was doing before, it always wakes up inside the saveContext code-because that’s where its instruction pointer was saved.
How does the new task know whether it is coming out of saveContext for the first time (i.e., in the process of going to sleep) or the second time (in the process of waking up)? It definitely does need to know the difference, so I’ve had to implement saveContext in a slightly sneaky way. Rather than saving the precise current instruction pointer, saveContext actually saves an address a few instructions ahead. That way, when the saved context is restored, execution continues from a different point in the saveContext routine. This also makes it possible for saveContext to return different values: nonzero when the task goes to sleep and zero when the task wakes up. The contextSwitch routine uses this return value to decide whether to call restoreContext. If contextSwitch did not perform this check, the code associated with the new task would never get to execute.

نقد و بررسیها
هنوز بررسیای ثبت نشده است.