Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
uCOSII the RealTime Kernel

uCOSII the RealTime Kernel

Ratings: (0)|Views: 30|Likes:
Published by dhanasekarp
micro controller UC/OS II manual
micro controller UC/OS II manual

More info:

Published by: dhanasekarp on Aug 23, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





My first book, “
µC/OS, The Real-Time Kernel 
” is now 6 years old and the publisher has sold wellover 15,000 copies around the world. When I was asked to do a second edition, I thought it would be a fairly straightforward task; a few corrections here and there, clarify a few concepts, add afunction or two to the kernel, etc. If you have a copy of the first edition, you will notice that
µC/OS-II, The Real-Time Kernel 
” is in fact a major revision. For some strange reason, I wasn’tsatisfied with minor corrections. Also, when my publisher told me that this time, the book would be a ‘hard cover’, I really wanted to give you your moneys worth. In all, I added more than 200new pages, and re-wrote the majority of the pages I did keep. I added a porting guide to help you port µC/OS-II to the processor of your choice. Also, I added a chapter that will guide you throughupgrading a µC/OS port to µC/OS-II.The code for µC/OS-II is basically the same as that of µC/OS except that it contains a number of new and useful features, is much better commented, and should be easier to port to processor architectures. µC/OS-II offers all the features provided in µC/OS as well as the following newfeatures:
A fixed-sized block memory manager,
A service to allow a task to suspend its execution for a certain amount of time(specified in hours, minutes, seconds and milliseconds),
User definable ‘callout’ functions that are invoked when:
a task is created,
a task is deleted,a context switch is performed,a clock tick occurs.
A new task create function that provides additional features,
Stack checking,
A function returning the version of µC/OS-II,
And more.
 µC/OS-II Goals
Probably the most important goal of µC/OS-II was to make it backward compatible with µC/OS (at least from anapplication’s standpoint). A µC/OS port might need to be modified to work with µC/OS-II but at least, the applicationcode should require only minor changes (if any). Also, because µC/OS-II is based on the same core as µC/OS, it is justas reliable. I added conditional compilation to allow you to further reduce the amount of RAM (i.e. data space) needed by µC/OS-II. This is especially useful when you have resource limited products. I also added the feature described inthe previous section and cleaned up the code.Where the book is concerned, I wanted to clarify some of the concepts described in the first edition and provideadditional explanations about how µC/OS-II works. I had numerous requests about doing a chapter on how to portµC/OS and thus, such a chapter has been included in this book for µC/OS-II.
 Intended Audience
This book is intended for embedded system programmers, consultants and students interested in real-time operatingsystems. µC/OS-II is a high performance, deterministic real-time kernel and can be embedded in commercial products(see Appendix F,
). Instead of writing your own kernel, you should consider µC/OS-II. You will find, as Idid, that writing a kernel is not as easy as it first looks.I’m assuming that you know C and have a minimum knowledge of assembly language. You should also understandmicroprocessor architectures.
What you will need to use µC/OS-II 
The code supplied with this book assumes that you will be using an IBM-PC/AT or compatible (80386 Minimum)computer running under DOS 4.x or higher. The code was compiled with Borland International’s C++ V3.1. Youshould have about 5 MBytes of free disk space on you hard drive. I actually compiled and executed the sample code provided in this book in a DOS window under Windows 95.To use µC/OS-II on a different target processor (than a PC), you will need to either port µC/OS-II to that processor yourself or, obtain one from µC/OS-II official WEB site athttp://www.uCOS-II.com. You will also need appropriatesoftware development tools such as an ANSI C compiler, an assembler, linker/locator and some way of debuggingyour application.
The µC/OS Story
Many years ago, I designed a product based on an Intel 80C188 at Dynalco Controls and I needed a real-time kernel.At my previous employer, I had been using a well known kernel (let’s call it kernel ‘A’) but, found it to be tooexpensive for the application I was designing. We then found a lower cost kernel ($1000 at the time) and started our design with it. Let’s call this kernel, kernel ‘B’. We spent about two months trying to get a couple of very simple tasksto run. We were calling the vendor almost on a daily basis to get help making this work. The vendor claimed that thiskernel was written in C. However, we had to initialize every single object using assembly language code. Althoughthe vendor was very patient, we decided that we had enough of this. Our product was falling behind schedule and wereally didn’t want to spend our time debugging this low cost kernel. It turns out that we were one of this vendor’s firstcustomer and the kernel was really not fully tested and debugged!To get back on track, we decided to go back and use kernel ‘A’. The cost was about $5000 for development seat andwe had to pay a per usage fee of about $200 for each unit that we shipped! This was a lot of money at the time, but it bought us some peace of mind. We got the kernel up and running in about 2 days! Three months into the project, oneof our engineers discovered what looked like a bug in the kernel. We sent the code to the vendor and sure enough, the bug was confirmed as being in the kernel. The vendor provided a 90 day warranty but, that had expired so, in order toget support, we had to pay an addition $500 per year for ‘maintenance’. We argued with the salesperson for a fewmonths that they should fix the bug since we were actually doing them a favor. They wouldn’t budge! Finally, wegave in, we bought the maintenance contract and the vendor fixed the bug six months later! Yes, six months later. Wewere furious but most importantly, late delivering our product. In all, it took close to a year to get our product to work reliably with kernel ‘A’. I must admit, however, that we never had any problems with it since.As this was going on, I naively thought, “Well, it can’t be that difficult to write a kernel. All it needs to do is save andrestore processor registers”. That’s when I decided to try it out and write my own (part time at night and on weekends).It took me about a year to get the kernel to be just as good (and in some ways better) than kernel ‘A’. I didn’t want tostart a company and sell it because there were already about 50 kernels out there so, why have another one?I then thought of writing a paper for a magazine. I first went to the “C User’s Journal (CUJ)” (the kernel was writtenin C) which, I had heard, was offering $100 per published page when other magazines were only paying $75 per page.My paper had 70 or so pages so, that would be a nice compensation for all the time I spent working on my kernel.
Unfortunately, the article was rejected! There were two reasons. First, the article was too long and the magazinedidn’t want to publish a series. Second, they didn’t want to have ‘another kernel article’.I then decided to turn to Embedded Systems Programming (ESP) magazine because my kernel was designed for embedded systems. I contacted the editor of ESP (Mr. Tyler Sperry) and told him that I had this kernel I wanted to publish in his magazine. I got the same response from Tyler as I did from the C Journal: “Not another kernel article?”I told him that this kernel was different, it was preemptive, it was comparable to many commercial kernels and that hecould put the source code on the ESP BBS (Bulletin Board Service). I was calling Tyler two or three times a week (basically begging him) until he finally gave in (he was probably tired of having me call him) and decide to publish thearticle. My article got edited down from 70 pages to about 30 pages and was published in two consecutive months(May 1992 and June 1992). The article was probably the most popular article in 1992. ESP had over 500 downloadsof the code from the BBS in the first month. Tyler may have feared for his life because kernel vendors were upset thathe published a kernel in his magazine. I guess that these vendors must have recognized the quality and capabilities of µC/OS (was called µCOS then). The article was really the first that exposed the internals of a real-time kernel so,some of the secrets were out.Just about the time the article came out in ESP, I got a call back from Dr. Bernard Williams at R&D Publications(publisher of CUJ), 6 months after the initial contact with CUJ. He had left a message with my wife and told her thathe was interested in the article!??! I called him back and told him something like: “Don’t you think you are a little bitlate with this? The article is being published in ESP.” Berney said: “No, No, you don’t understand, because the articleis so long, I want to make a book out of it.” Initially, Berney simply wanted to publish what I had (as is) so the book would only have 80 or so pages. I said to him, “If I going to write a book, I want to do it right.” I then spent about 6months adding contents to what is now know as the first edition. In all, the book had about 250 pages to it. I changedthe name of µCOS to µC/OS because ESP readers had been calling it ‘Mucus’ which didn’t sound too healthy! Cometo think of it, maybe it was a kernel vendor that first came up with the name. Anyway,
µC/OS, The Real-Time Kernel 
 was then born. Sales were somewhat slow to start. Berney and I projected that we would sell about 4000 to 5000copies in the life of the book but at that rate, we would be lucky if it sold 2000 copies. Berney insisted that these thingstake time to get known so, he continued advertising in CUJ for about a year.A month or so before the book came out, I went to my first Embedded Systems Conference (ESC) in Santa Clara, CA(September 1992). I then met Tyler Sperry for the first time and I showed him the first draft copy of my book. He veryquickly glanced at it and said something like: “Would you like to speak at the next Embedded Systems Conference inAtlanta?” Not knowing any better, I said “Sure, what should I talk about?” He said what about “Using small real-timekernels?” I said “Fine”. On the trip back from California, I was thinking “What did I get myself into? I’ve never spoke in front of a bunch of people before! What if I make a fool of myself? What if what I speak about is commonknowledge? Those people pay good money to attend this conference.” For the next six months, I prepared my lecture.At the conference, I had about 70+ attendees. In the first twenty minutes I must have lost one pound of sweat. After my lecture, I had a crowd of about 15 or so people come up to me and say that they were very pleased with the lectureand liked my book. I got re-invited back to the conference but could not attend the one in Santa Clara that year (i.e.1993). I was able to attend the next conference in Boston (1994) and I have been a regular speaker at ESC ever since.For the past couple of years, I’ve been on the conference Advisory Committee. I now do at least 3 lectures at everyconference and each have average attendance of between 200 and 300 people! My lectures are almost always rankedamongst the top 10% of the conference.To date, we sold well over 15,000 copies or 
µC/OS, The Real-Time Kernel 
around the world. I received and answeredwell over 1000 e-mails from the following countries:In 1995,
µC/OS, The Real-Time Kernel 
was translated in Japanese and published in a magazine called
inJapan. µC/OS has been ported to the following processors:Analog Devices AD21xxAdvanced Risc Machines ARM6, ARM7Hitachi 64180, H8/3xx, SH seriesIntel 80x86 (Real and PM), Pentium, Pentium-II, 8051, 8052, MCS-251, 80196, 8096Mitsubishi M16 and M32

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
Vô Cực liked this
wdragon75845 liked this
jmtiti liked this
boosala liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->