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

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

?? ctask.doc

?? 用TC2實現的DOS多任務功能
?? DOC
?? 第 1 頁 / 共 5 頁
字號:

        Now take two tasks, which call this routine. Task1 calls it with
        val=3, Task2 with val=7. What will be the return value for both
        tasks? You never know. There are three possible outcomes:

          1) The tasks execute sequentially. Task1 will get 6, and Task2
             14 as a result. This is what one normally expects.

          2) Task1 runs up to "temp = val", then is interrupted by the
             timer. Task2 executes, and gets 14 as result. Then Task1
             continues. Return for Task1 is 14.

          3) Task2 runs up to "temp = val", then is interrupted by the
             timer. Task1 executes, and gets 6 as result. Then Task2
             continues. Return for Task2 is 6.

        add to this the effects of optimization, and a loop, and the
        outcome is completely random.

        Most routines in the C library will not explicitly do something
        like this, but all functions that

             - do file I/O (read, write, printf, scanf, etc.) or
             - change memory allocation (malloc, free, etc.)


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

        have to use some static data to do buffering, or to store the
        chain of memory blocks in. Interrupting such an operation may
        have disastrous effects. The most devilish aspect of non-
        reentrancy is that the effects are unpredictable. Your program
        may run 1000 times without any error, and then on the 1001th time
        crash the system so completely that only the big red switch will
        help.

        So what can you do about it? A lot. There are several ways to
        protect "critical regions" from being entered in parallel. The
        most simple method is to disable interrupts. This, however,
        should be used only for *very* short periods of time, and not for
        rou-tines that might themselves re-enable them (like file-I/O). A
        better method is to temporarily disable task preemption. The
        routines tsk_dis_preempt and tsk_ena_preempt allow this form of
        short-term task switch disable. Interrupts may still be
        processed, but tasks will not be preempted. The best way is to
        use a "resource". A resource is a special kind of event, which
        only one task can possess at a time. Requesting the resource
        before entering the routine, and releasing it afterwards, will
        protect you from any other task simultaneously entering the
        critical region (assuming that this task also requests the
        resource).

        It is also reasonably safe to use file-I/O without protection if
        it goes to different files. The C file control blocks for
        different files are distinct, so there will be no conflict
        between tasks. Since DOS access is automatically protected by
        CTask, concurrent file I/O is possible.

        What you may NEVER do is to use a non-reentrant routine that is
        not protected by an interrupt disable from an interrupt handler.
        An interrupt handler is not a task, and so can not safely request
        a resource or disable task preemption. This is the reason why the
        CTask routines generally disable interrupts before manipulating
        the internal queues rather than only disabling task preemption.


                                    Deadlocks

        One thing to watch out for when using resources or similar event
        mechanisms is not to get into a situation where Task 1 waits for
        a resource that Task 2 has requested, while at the same time Task
        2 waits for a resource that Task 1 already has. This situation is
        called a deadlock (or, more picturesque, deadly embrace), and it
        can only be resolved with outside help (e.g. waking up one of the
        tasks forcibly). To illustrate, consider the following example:






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

             void far task_1 ()
             {
               ...
               request_resource (&rsc1, 0L);
               request_resource (&rsc2, 0L);
               ...
             }

             void far task_2 ()
             {
               ...
               request_resource (&rsc2, 0L);
               request_resource (&rsc1, 0L);
               ...
             }

        Since interrupts are always enabled on return from a task switch,
        even if the statements are enclosed in a critical region, there
        is no guarantee that the request_resource calls will be executed
        without interruption. In this example, the problem is obvious,
        but in a more complex application, where resource requests or
        other waits might be buried in some nested routine, you should
        watch out for similar situations. One way to avoid problems would
        be in this example to change task_2 to

             void far task_2 ()
             {
                  int again;
                  ...
                  do {
                       request_resource (&rsc2, 0L);
                       if (again = c_request_resource (&rsc1))
                          {
                          release_resource (&rsc2);
                          delay (2L);
                          }
                     } while (again);
                  ...
             }

        Note that this is only one of many possible approaches, and that
        this approach favors task_1 over task_2.

        You should also take care not to kill tasks that currently own a
        resource. CTask will not detect this, and the resource will never
        be freed.







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

                                   Using CTask

        CTask comes archived with both source and binaries. The binary
        version is compiled in the large model, but since the precompiled
        kernel routines don't use any functions from the C library, you
        can use all functions in small or other model programs (except
        Turbo C's Tiny and Huge models). The include files provided
        specify all model dependencies, so you don't have to use the
        large model for your application, but always remember to include
        "tsk.h" for the type definitions and function prototypes.

        The C source files will work without changes for both Microsoft
        and Turbo C. The library files are not compatible, so use
        "ctaskms.lib" for Microsoft, and "ctasktc.lib" for Turbo C.

        In the distributed configuration (i.e. dynamic allocation of
        control blocks enabled), the file TSKALLOC.C must be added to the
        library or separately linked after compiling it *in the same
        model as the main program*. This file uses C-library routines,
        and thus must match the main program's memory model. The same
        goes for TSKSNAP.C, an optional snapshot-dump utility, and
        CONOUT.C, the sample console output handler. The provided
        "ctsupms.lib" and "ctsuptc.lib" files have been compiled in the
        large model, and may only be used with large model programs.

        Turbo C's huge model uses a different segment setup for data
        segments. This requires using a special data segment for all
        CTask data, and compilation of the CTask kernel in huge model.
        For the assembler files, the symbol TC_HUGE must be defined
        during assembly, the C files must be compiled with the Data-
        Segment and BSS-Segment naming options. Make-files for Turbo C
        Huge model are included.


                              Configuration Options

        The file TSKCONF.H contains a number of #define's that allow you
        to configure some CTask features. In general, you should
        recompile all of CTask when changing one of the flags. Version
        2.1 collects all configuration options for both Assembler and C
        in this file.

        The entries are

        CODE_SHARING
             If TRUE, the generated kernel supports code sharing. This
             requires the entry points to load DS on entry, and compi-
             lation with Large model (MSC) or Huge model (TC).

             This option is normally disabled (FALSE).



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

        NEAR_CODE
             If TRUE, all CTask routines are 'near'. Use only with small
             or compact model. You will have to change the make-files so
             the compiler model is no longer Large, and the code segment
             is not named, when turning on this flag. The default is
             FALSE. Setting this option TRUE will save code, and make
             calls faster, but the library will no longer be model
             independent.

             This option is normally disabled (FALSE).

        LOCALS_FAR
             If TRUE, internal CTask routines ar 'far'. This might be
             necessary if your compiler/linker does not allow placing all
             CTask kernel code in a common segment. Do not set this flag
             if NEAR_CODE is set.

             This option is normally disabled (FALSE).

        CALL_PASCAL
             Use Pascal calling sequence for CTask routines.  This may
             save some code, but may cause naming conflicts if your
             compiler limits external Pascal names to 8 characters.

             This option is normally disabled (FALSE).

        TC_HUGE
             (Assembler only) Define TC_HUGE for use with the Turbo C
             Huge model, and if it is desired to separate CTask's data
             from the normal data segment. This flag causes the
             CTASK_DATA segment to be defined, (class is DATA) and DS to
             be loaded with this segment on function entry. The C
             functions in the CTask kernel must be compiled to use the
             same data segment.

             This option is normally disabled (undefined).

        LOAD_DS
             (Assembler only) Define LOAD_DS to reload the data segment
             on entry to global functions. This flag must be defined for
             TC_HUGE. It can also be defined if the data segment can not
             safely be assumed to be loaded in DS on function entry, for
             example if the code sharing feature of version 2.1 is used.
             The C routines must be compiled with the necessary compiler
             switches or the _loadds keyword in this case.

             This option is normally disabled (undefined).






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

        ROM_CODE
             (Assembler only) Define ROM_CODE TRUE for embedded systems
             using ROM-based code. This option disables storing variables
             in the code segment in some modules. Note that most DOS-
             related modules are not ROMable.

             This option is normally disabled (FALSE).

        FAR_STACK
             (Assembler only) Define FAR_STACK TRUE to save some space in
             the default DGROUP. With this define TRUE, the local stacks
             for the scheduler, the timer, and the interrupt handlers,
             are allocated in a separate segment. With Turbo C, you may
             have to edit the "c0.asm" startup module to accomodate the
             new segment.

             This option is normally disabled (FALSE).

        TSK_DYNAMIC
             If TRUE, you can let CTask dynamically create task and event
             control blocks, task stacks, and pipe buffers, by passing
             NULL as the block address. Since this requires the C runtime
             allocation calls, it is not suitable for non-DOS appli-
             cations (except if you provide your own memory allocation
             routines).

             This option is normally enabled (TRUE).

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩国产在线一| 欧洲亚洲国产日韩| 成人免费一区二区三区视频| 99视频精品免费视频| 一区二区三区四区不卡在线| 欧美日韩专区在线| 另类成人小视频在线| 国产欧美日韩精品a在线观看| 成人午夜av电影| 亚洲一区视频在线| 欧美一区二区三区视频免费 | 亚洲午夜久久久久久久久电影网| 欧美日本不卡视频| 国产乱码精品1区2区3区| 国产精品传媒入口麻豆| 欧美日韩情趣电影| 韩国三级在线一区| 中文字幕亚洲综合久久菠萝蜜| 在线观看精品一区| 久久99久久精品| 国产精品沙发午睡系列990531| 91国模大尺度私拍在线视频| 蜜桃av一区二区在线观看| 中文字幕精品综合| 欧美日韩国产另类一区| 国产精品自拍一区| 一区二区三区国产精华| 精品欧美一区二区久久| 99这里只有久久精品视频| 日韩av高清在线观看| 国产视频一区二区在线观看| 在线观看亚洲成人| 国产经典欧美精品| 午夜伦理一区二区| 欧美韩国日本不卡| 欧美精品乱码久久久久久| 国产sm精品调教视频网站| 性做久久久久久免费观看 | 日韩欧美久久一区| 99re在线精品| 国产在线精品一区二区夜色| 亚洲精品ww久久久久久p站| 精品99一区二区三区| 在线观看视频欧美| 高清不卡一区二区| 秋霞午夜鲁丝一区二区老狼| 1024精品合集| 久久久五月婷婷| 7777精品伊人久久久大香线蕉最新版| 本田岬高潮一区二区三区| 日本中文字幕一区| 一区二区在线观看免费视频播放 | 国产精品久久久久久户外露出| 7777精品伊人久久久大香线蕉经典版下载 | 色域天天综合网| 久久激情五月激情| 亚洲午夜在线视频| 国产精品成人网| 久久影院午夜片一区| 欧美色视频在线观看| 成人一区二区三区视频| 久久99国产精品久久| 亚洲国产综合91精品麻豆| 国产精品情趣视频| 26uuu精品一区二区| 在线不卡一区二区| 欧洲精品在线观看| www.亚洲激情.com| 国产一区二区主播在线| 爽爽淫人综合网网站| 亚洲免费观看高清| 国产精品女主播在线观看| 午夜亚洲国产au精品一区二区| 国产精品久久久久久久久搜平片| 精品国产成人在线影院 | 欧美日韩精品专区| 91成人免费在线视频| 99久精品国产| 成人午夜激情影院| 国产福利91精品| 韩国av一区二区三区在线观看| 奇米888四色在线精品| 亚洲福利电影网| 一区二区高清免费观看影视大全| 国产精品福利一区二区| 中文字幕欧美三区| 国产色婷婷亚洲99精品小说| 久久综合九色综合欧美就去吻| 91精品国产美女浴室洗澡无遮挡| 欧美日韩免费一区二区三区视频| 91免费国产在线观看| 97se狠狠狠综合亚洲狠狠| www.欧美亚洲| 9久草视频在线视频精品| 成人av在线一区二区| 成人激情免费电影网址| 成人午夜在线播放| 国v精品久久久网| 丁香亚洲综合激情啪啪综合| 国产99久久精品| 成人毛片视频在线观看| 成人午夜激情片| caoporen国产精品视频| 91在线观看高清| 色噜噜狠狠一区二区三区果冻| 日本国产一区二区| 欧美色精品天天在线观看视频| 欧美色倩网站大全免费| 91精品欧美久久久久久动漫| 91精品欧美一区二区三区综合在| 日韩午夜在线观看| 精品国产一区二区三区忘忧草 | 亚洲人123区| 一区二区三区日韩在线观看| 亚洲国产另类av| 日韩和的一区二区| 韩国成人在线视频| 成人少妇影院yyyy| 99国产精品久久久久久久久久 | 在线电影一区二区三区| 欧美一区二区三区小说| 亚洲精品一区二区在线观看| 国产三级一区二区三区| 中文字幕一区免费在线观看| 亚洲精品美国一| 亚洲成a人片综合在线| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美色综合久久| 午夜精品免费在线观看| 理论片日本一区| 国产91丝袜在线18| 在线日韩国产精品| 91精品国产综合久久婷婷香蕉| 精品少妇一区二区三区免费观看 | 欧美图片一区二区三区| 91精品在线观看入口| 久久理论电影网| 亚洲欧美另类久久久精品2019| 亚洲高清免费观看高清完整版在线观看| 日韩中文欧美在线| 精品一区二区三区av| 99久久综合国产精品| 欧美人狂配大交3d怪物一区| 久久亚洲综合色一区二区三区| 国产精品电影一区二区三区| 亚洲成人动漫在线观看| 国产综合色视频| av电影一区二区| 91精品久久久久久久99蜜桃| 国产午夜精品久久| 一区二区三区欧美日| 久久精品国产秦先生| 午夜精品123| 国产剧情一区二区| 欧美三级在线播放| 久久免费美女视频| 亚洲午夜激情av| 欧美成人一区二区三区片免费| 日本一区二区三区四区| 蜜臀久久99精品久久久久久9| 国产资源在线一区| 91免费视频网| 精品日韩一区二区三区免费视频| 国产精品久久久久久久久动漫| 日韩高清不卡一区二区三区| 高清国产一区二区| 欧美色偷偷大香| 国产欧美一区视频| 婷婷成人综合网| 成人一区二区视频| 在线播放/欧美激情| 中文字幕一区不卡| 精品一区二区成人精品| 欧美综合久久久| 国产亚洲欧美激情| 婷婷综合另类小说色区| 成人黄色小视频| 日韩欧美国产麻豆| 亚洲精品久久久蜜桃| 国产伦理精品不卡| 欧美美女喷水视频| 自拍偷在线精品自拍偷无码专区| 激情综合网激情| 欧美日韩一区二区在线观看| 国产精品美女久久久久高潮| 久久成人羞羞网站| 欧美日韩国产高清一区| 国产精品传媒入口麻豆| 国产一区二区三区精品视频| 欧美男人的天堂一二区| 亚洲欧洲99久久| 国产精品影音先锋| 91精品国产综合久久久蜜臀粉嫩| 亚洲日本成人在线观看| 国产成人精品免费在线| 精品乱人伦一区二区三区| 亚洲超丰满肉感bbw| 色综合久久综合网97色综合| 欧美国产乱子伦| 国产乱人伦精品一区二区在线观看 |