TransBlock 2.54 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
                                Wimp_TransferBlock

        There are a number of cases when transfering memory between tasks under the
Wimp, these are summarised below (CT current task, H high memory ie non app space, 
a & b arbitrary tasks) There are a few sub cases involving length of copy, overlap etc.:
        H  <->  H
        CT <->  H
        CT <-> CT       These are all ok, no paging, standard copy
        
        a  <->  a
        a  <->  H       These require some, possibly all of 'a' to paged in
                        possibly at the expense of paging out CT, this is
                        an unlikely use of transfer block though.

        CT <->  a       This is probably the most likely use of the call
                        and should be the most efficient, can do:
                        i) if CT takes all space a bit must be paged out
                           - problem if length of transfer is whole space
                             must be done in two steps
                        ii) if only part of 'a' can fit in unused area
                            page at a time copy is probably best (otherwise
                            have to check which bits of CT can be paged out-
                            they may be in the copy range, in which case need
                            to page back etc.)
                        iii) both CT and 'a' can happily live in the area
                             then usual copy

        a  <->  b       Unlikely, probably page out bit of CT and use page by
                        page copy.

Obviously to cater for all of these separately would take a lot of code, unfortunately
use of a generic routine would make the most common cases inneficient. For Wimp 3.22
the following method was used, which is a compromise, catering for all cases but making
the most common ones more efficient.

Is the transfer big? ie. >X where X is just under one half of the application space
        Yes?    Then Copy X bytes now then repeat with length-X
        
        Is one of the tasks the current task?
                Yes?    Then is the size of the current task+ ammount to copy > app space?
                        Yes?    Then page out current task
                No?     Is twice the copy length + current task size > app space?
                        Yes?    Then page out current task

        For both tasks, page in only the area that is required for the copy, unless a task
        is the current task and as such already paged in.

        Do the copy, page out copiy areas, page in the old task if necessary.