亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ctask.doc

?? 用TC2實現的DOS多任務功能
?? DOC
?? 第 1 頁 / 共 5 頁
字號:
        CTask allows your C program to do many different things at the
        same time by switching the processor between the tasks you de-
        fine. And since most of the time your program is waiting for some
        slow device (like the human hand) to provide feedback, this
        switching is completely transparent, and will not noticeably slow
        your program down.


                              Switching the Context

        So what is needed to allow the user to edit a file while at the
        same time downloading another and printing a third? First, you
        have to have some form of "context switching". This means that
        you have to be able to interrupt the processing of the download
        when the user presses a key, process the key, and return to the
        download "task" at the exact same point it was interrupted. One
        solution to this would be to include a poll for the keyboard at
        several points in the download routine, and call the editor task
        when a key is available.  But apart from cluttering your code
        with lots of unrelated calls, there is another problem. What if
        the operation the user requested is more involved than just
        putting the character on the screen, like writing the file to
        disk? This might take so long that your download times out. There
        must be a way to pass control back and forth between the two
        tasks, such that no task is delayed for an extended period of
        time, and also to activate the print spooler task at some defined
        interval to output the data to the printer. This context
        switching is called "scheduling" in CTask. The "scheduler" is
        
        
        Ctask Manual       - Version 2.2 - 90-10-12 -              Page 2


        invoked on every system timer tick, and will save the context of
        the current task. The scheduler then takes the first element from
        the queue of tasks that are eligible to be run, and restores the
        context of this task, returning to the point where the task was
        interrupted. This switching is completely automatic, and requires
        no special programming in the tasks itself. All you have to do is
        to tell CTask that there are three tasks, the download task, the
        spooler task, and the editor task.


                                  You have Mail

        All you have to do for context switching, that is. There's a bit
        more to multitasking than meets the eye. How do you tell the
        spooler task what files to spool, and the download task what
        files to download? You can't call a task like an ordinary func-
        tion, so what you need for this is "inter-task communication".
        There must be a way to pass a message containing the filename to
        be printed to the spooler task, and there are several in CTask,
        one of them the "mailbox". The spooler can use a CTask call,
        wait_mail, to wait for a message to arrive at its mailbox. As
        long as nothing arrives, the spooler task will no longer be
        scheduled, so if there is nothing to print, it will not use any
        processor time. When you send a message with send_mail to the
        mailbox, the spooler will wake up, and process the file. You can
        also send more file name messages to the spooler while it still
        prints a file, leaving the messages in the mailbox until the
        spooler is ready to process the next file.


                             Reentrancy and Resources

        This last example seems innocent enough, but there's a big stumb-
        ling block hidden in it. You allocate the file name messages in
        the controlling task with malloc, and you free them in the
        spooler with free, no problem, right? Wrong, there is a big
        problem, "reentrancy". Reentrancy means that you can re-enter a
        routine while another task is already using it, and that this
        will not disturb the operation of the interrupted task. But
        malloc and free share and modify global data, the chain of free
        memory blocks. Imagine the following: You just called malloc from
        the controlling task. Malloc has loaded the address of a free
        element into a local variable, and is about to write back the
        pointer to the next free element into the last. At exactly this
        moment, the timer ticks, and the spooler is activated. It has
        just finished printing, so it calls free. Free steps through the
        chain of free blocks to find the right place to insert the block.
        According to Murphy's law, it will find just the place where
        malloc is about to write back the pointer. Free coerces the
        elements, points the next pointer to the element malloc just
        wants to take off the chain, and returns. Malloc writes its next
        pointer into the middle of the newly coerced block, and now re-
        turns an element which is still in the free list. Compared to the
        
        
        Ctask Manual       - Version 2.2 - 90-10-12 -              Page 3


        job of finding this kind of bug, stepping in for Tantalus may
        feel like a vacation. This kind of problem code is called a
        "critical region". There must be a way to make sure that no two
        tasks simultaneously enter such a region, and, you guessed it,
        CTask provides one, the "resource". When you request a resource
        in one task, all other tasks trying to request the same resource
        after that are put to sleep until you call release_resource. Only
        then will the highest priority task that waits for the resource
        wake up, and get access to the protected region. So you would
        have to substitute malloc and free calls in your routines with
        calls to functions that first request a resource, execute the
        function, and then release the resource.


                                    DOS Access

        But, you might ask, isn't there another reentrancy problem in
        this example, since both the spooler and the download task might
        simultaneously call DOS to do their file-I/O, and DOS is not
        reentrant? Do I have to substitute all my calls to fread and
        fwrite, too? The answer to this, luckily, is no. CTask traps all
        your DOS calls, and automatically encloses them in the necessary
        resource request and release calls, so you don't have to worry
        about trashing your disk by simultaneous DOS requests. The
        limited multitasking capabilities of DOS are exploited to allow
        some parallel processing in DOS, and CTask will also detect and
        handle DOS calls by resident background programs like the DOS
        PRINT utility.


                              Handling the Keyboard

        CTask also allows you to circumvent DOS for keyboard input, so
        that waiting for the keyboard will not block other tasks from
        access to DOS functions. Previous versions of CTask used a "pipe"
        to store all keyboard input. Starting with version 1.2, CTask
        uses a "flag" to signal that keyboard input might be available. A
        "flag" is another form of inter-task communication that just sig-
        nals that some event occurred, without passing any specific data.
        The reason for using flags in the keyboard handler is compati-
        bility to TSR's. If a keyboard interrupt occurs, the interrupt
        handler just sets a flag, and passes on the interrupt. The key-
        board routines wait for this flag to be set, and then check the
        keyboard buffer if a character has arrived. If the keyboard buf-
        fer is empty, the flag is again cleared, and the keyboard rou-
        tines put the waiting task to sleep again, so the processor is
        free to do more interesting things than to loop waiting for the
        user to press a key.





        
        
        Ctask Manual       - Version 2.2 - 90-10-12 -              Page 4


                             Serial I/O and Timeouts

        The "pipe" is similar to the mailbox in that you can wait for
        items to be sent to a pipe. But unlike mailboxes, pipes use their
        own buffer to store the items (which are limited to bytes and
        words), so you don't have to allocate mail blocks for each item.
        When waiting on the pipe, your task is put to sleep, freeing the
        processor. Pipes are used for the serial I/O handler included
        with CTask that makes some of the work you've put into your
        communications package obsolete. When outputting data to the
        serial port via the CTask routines, the data is buffered in a
        pipe, and incoming data is also placed in a pipe. All interrupt
        handling, and the processing of modem status and XON/XOFF proto-
        cols, is done by CTask, so you can concentrate on implementing
        the higher level protocols. Since CTask allows all calls that
        wait for pipes, mail, and other events, to specify a timeout that
        is based on the system tick, you do not have to resort to timed
        waiting loops to detect communication line faults. You simply
        give a time limit on the wait call, and if that limit expires,
        the wait routine will return with an error indication.


                                    Priorities

        If the protocol you implement requires fast responses to incoming
        blocks, you can influence the response of CTask to your comm
        task's needs by giving this task a higher priority. CTask allows
        65535 different priority levels, and tasks having higher priority
        are scheduled before tasks with lower priority. Also, high prio-
        rity tasks will get access to mail, pipes, and resources, before
        other tasks. It might even be sensible to split the comm task
        into two separate tasks, one of high priority that assembles the
        incoming bytes into blocks and handles the protocol, and a lower
        priority task that reads the received blocks from a mailbox and
        stores them on the disk. In extremely time critical applications,
        you can even turn off task preemption, so the timer tick will no
        longer cause a task switch.


                              Change to your liking

        CTask provides all basic building blocks for implementing
        concurrent programs in an easy and comprehensible way. Since
        CTask is mainly implemented in C, it may not be the fastest
        possible system, but due to the straightforward design which uses
        few shortcuts, modifying the sources to suit your needs and taste
        can be done without weeks of studying assembler code that
        squeezes every microsecond from the processor. CTask is public
        domain code, and there are no restrictions on its use. It is
        distributed in source form, so you are free to change all aspects
        of the package. Multitasking programs, especially in embedded
        applications, tend to be very diverse in their needs for specific
        constructs. So although CTask is ready to run under DOS, and is
        
        
        Ctask Manual       - Version 2.2 - 90-10-12 -              Page 5


        easily adaptable for embedded applications, you should see CTask
        more as a starting point for your own thoughts, and as a toolbox
        from which you can pick the instruments you need, than as a
        finished and fixed block of code you simply plug into your
        application.
















































        
        
        Ctask Manual       - Version 2.2 - 90-10-12 -              Page 6


                                  General Notes


                         What can CTask NOT be used for?

        CTask is not intended to provide for multitasking on the command
        level of MS-DOS. Although version 1.2 of CTask added the ability
        to TSR and spawn other programs, and to communicate between
        multiple copies of CTask, a full DOS-process management (which
        would have to include keeping track of memory allocation and DOS
        process control blocks) is not included. Adding this functio-
        nality would not be trivial (although certainly worthwhile).

        CTask also is not a true "Real-Time" multitasking system. Due to
        the completely dynamic structure of tasks and events, and the
        minimal restrictions on what interrupt handlers may do, it is
        nearly impossible to calculate a maximum interrupt or task switch
        latency. If you have critical timing requirements, you should
        consider getting a professional package like AMX. CTask has been
        used successfully in embedded control applications, and if your
        timing requirements are not that critical, or you're ready to
        take up the task of measuring and calculating latencies with your
        specific task setup, CTask may be useful even for Real-Time
        applications. However, you're more or less on your own in this
        field.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩亚洲电影在线| 久久成人18免费观看| 久久精品人人做人人爽97| 欧美亚洲国产一区在线观看网站| 国产精品一线二线三线| 精品一区二区成人精品| 久久精品99国产精品日本| 久99久精品视频免费观看| 免费成人性网站| 蜜桃免费网站一区二区三区| 午夜久久久久久久久| 蜜臀av性久久久久av蜜臀妖精| 日日摸夜夜添夜夜添精品视频| 日本欧美一区二区在线观看| 男人的j进女人的j一区| 国产在线精品不卡| 国产精品中文欧美| 成人午夜精品一区二区三区| aaa国产一区| 欧洲精品在线观看| 欧美一卡二卡在线观看| 国产喂奶挤奶一区二区三区| 亚洲精选在线视频| 亚欧色一区w666天堂| 久久国产麻豆精品| 成人h版在线观看| 91国产精品成人| 精品日韩一区二区三区| 国产精品成人免费| 日本中文一区二区三区| 懂色av一区二区夜夜嗨| 在线观看成人小视频| 日韩免费高清电影| 中文字幕综合网| 免费在线观看日韩欧美| 高清久久久久久| 欧美在线一区二区三区| 久久蜜桃香蕉精品一区二区三区| 国产精品国产三级国产有无不卡| 亚洲综合激情另类小说区| 国产精品一线二线三线精华| 欧美系列一区二区| 国产欧美精品区一区二区三区| 一级日本不卡的影视| 国产精品一区在线观看你懂的| 在线精品视频一区二区三四| 久久久.com| 性久久久久久久久| 色婷婷亚洲精品| 国产日韩精品一区二区浪潮av| 亚洲国产精品一区二区www在线| 国产精品一区2区| 日韩午夜在线观看| 亚洲一区二区精品视频| 成人高清在线视频| 欧美经典一区二区三区| 日本免费在线视频不卡一不卡二| 波波电影院一区二区三区| 欧美成人精品二区三区99精品| 悠悠色在线精品| www.成人在线| 国产一区二区剧情av在线| 粉嫩高潮美女一区二区三区| 日本一区二区三区四区在线视频 | 亚洲欧美偷拍卡通变态| 精品一区二区三区免费视频| 91丨porny丨首页| 亚洲国产精品成人久久综合一区| 奇米影视一区二区三区小说| 欧美图片一区二区三区| 1区2区3区国产精品| 99久久精品免费看国产免费软件| 久久久久久免费网| 国产一区二区三区在线观看精品| 91麻豆精品国产91久久久久| 亚洲一区国产视频| 欧美色爱综合网| 亚洲成a人片在线不卡一二三区| 91成人网在线| 亚洲综合无码一区二区| 欧美丝袜丝交足nylons图片| 亚洲精品久久久蜜桃| 欧美性大战xxxxx久久久| 午夜伦理一区二区| 欧美成va人片在线观看| 韩国欧美国产1区| 亚洲国产精品二十页| 99久久精品国产观看| 亚洲午夜电影在线观看| 欧美日本乱大交xxxxx| 日本aⅴ精品一区二区三区| 日韩欧美国产wwwww| 国产精品自产自拍| 亚洲欧美一区二区三区久本道91 | 日韩制服丝袜av| 精品精品国产高清a毛片牛牛| 久久草av在线| 日韩伦理av电影| 欧美精品视频www在线观看| 美美哒免费高清在线观看视频一区二区 | 亚洲视频一区在线| 欧美日韩另类国产亚洲欧美一级| 麻豆精品在线视频| 久久精品人人做| 欧美精品久久一区| 国产精品77777| 亚洲国产另类av| 国产欧美一区二区三区在线看蜜臀| 91社区在线播放| 精品一区二区三区在线视频| 日韩理论片网站| 亚洲精品在线免费观看视频| 一本色道久久综合精品竹菊 | 欧美www视频| 成人久久18免费网站麻豆| 最新国产の精品合集bt伙计| 色哟哟国产精品| 精品一区二区三区免费观看| 欧美韩国日本一区| 99麻豆久久久国产精品免费| 中文字幕一区二区三区在线观看 | 国产真实精品久久二三区| 国产蜜臀97一区二区三区| 99精品桃花视频在线观看| 午夜不卡av在线| 中文字幕中文字幕一区| 欧美电影一区二区三区| 国内精品免费在线观看| 亚洲欧美日韩成人高清在线一区| 欧美色综合影院| 91亚洲国产成人精品一区二三| 一区二区三区美女视频| 精品久久久久久最新网址| 99久久免费视频.com| 日韩中文字幕不卡| 一区二区三区在线观看国产| 久久综合色8888| 欧美专区日韩专区| 国产高清精品网站| 日韩黄色免费电影| 亚洲va韩国va欧美va| 国产精品伦理在线| 日韩免费高清视频| 欧美精品自拍偷拍| 国产91高潮流白浆在线麻豆| 久久不见久久见中文字幕免费| 夜夜精品视频一区二区| 久久精品欧美日韩精品| 欧美日韩精品久久久| 欧日韩精品视频| 丰满少妇久久久久久久| 免费成人你懂的| 亚洲一二三级电影| 一区在线中文字幕| 亚洲综合在线五月| 中文字幕在线不卡一区| 国产日韩精品一区二区浪潮av| 日韩欧美一二区| 91久久精品一区二区三| 91久久精品一区二区三| av网站一区二区三区| 国产91丝袜在线18| 麻豆91在线看| 国产精品一二三四| 国产一区二区三区精品欧美日韩一区二区三区 | 亚洲午夜久久久久中文字幕久| 国产精品美女久久久久aⅴ| 欧美精品一区二区三区高清aⅴ| 欧美一区二区三区精品| 91精品国产综合久久福利| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 国产成人在线视频网址| 国产高清亚洲一区| 成人av集中营| 成人高清av在线| 欧美日韩精品一二三区| 911精品国产一区二区在线| 色噜噜狠狠色综合欧洲selulu| 91在线看国产| 91社区在线播放| 欧美日韩你懂得| 99国内精品久久| 精品视频一区三区九区| 91精品婷婷国产综合久久竹菊| 欧美电影免费观看完整版| 中文字幕一区免费在线观看| 亚洲精品欧美在线| 日本不卡的三区四区五区| 精品一区二区三区免费视频| 91美女视频网站| 欧美性猛片aaaaaaa做受| 7777精品伊人久久久大香线蕉超级流畅| 欧美日韩亚洲高清一区二区| 精品国产麻豆免费人成网站| 久久综合色天天久久综合图片| 欧美—级在线免费片| 一区二区三区国产豹纹内裤在线| 一区二区久久久久| 激情综合网天天干| 成人福利视频网站|