Changes between Version 23 and Version 24 of io_operations
- Timestamp:
- Nov 3, 2016, 5:15:42 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
io_operations
v23 v24 13 13 * '''External peripherals''' are accessed through a bridge located in one single cluster (called ''cluster_io'', identified by the ''io_cxy'' parameter in the arch_info description). They are shared ressources that can be used by any thread running in any cluster. Examples are the generic IOC device (Block Device Controller), the generic NIC device (Network Interface Controller), the generic TXT device (Text Terminal), the generic FBF device (Frame Buffer for Graphical Display Controller). 14 14 15 * '''Internal peripherals''' are replicated in all clusters. Each internal peripheral is associated to the local kernel instance, but can be accessed by an t thread running in any cluster. There isvery few internal peripherals. Examples are the generic ICU device (Interrupt Controller Unit), or the generic MMC device (L2 Cache Configuration and coherence management).15 * '''Internal peripherals''' are replicated in all clusters. Each internal peripheral is associated to the local kernel instance, but can be accessed by any thread running in any cluster. There are very few internal peripherals. Examples are the generic ICU device (Interrupt Controller Unit), or the generic MMC device (L2 Cache Configuration and coherence management). 16 16 17 17 ALMOS-MK supports ''multi-channels'' external peripherals, where one single peripheral controller contains N channels that can run in parallel. Each channel has a separated set of addressable registers, and each channel can be used by the OS as an independent device. Examples are the TXT peripheral (one channel per text terminal), or the NIC peripheral (one channel per MAC interface). 18 18 19 The set of available peripherals, and their loca lisation in a given many-core architecture must be described in the '''arch_info.py''' file. For each peripheral, the composite index is implemented as a 32 bitsinteger, where the 16 MSB bits define the type, and the 16 LSB bits define the subtype.19 The set of available peripherals, and their location in a given many-core architecture must be described in the '''arch_info.py''' file. For each peripheral, the composite index is implemented as a 32 bit integer, where the 16 MSB bits define the type, and the 16 LSB bits define the subtype. 20 20 21 21 == B) Generic Devices APIs == 22 22 23 To represent the available peripherals in a given man icore architecture, ALMOS-MK uses generic ''device descriptors'' (implemented by the ''device_t'' structure). For multi-channels peripherals, ALMOS-MK defines one ''device descriptor'' per channel. this descriptor contains the functional index, the implementation index, the channel index, and the physical base address of the segment containing the addressable registers for this peripheral channel.23 To represent the available peripherals in a given manycore architecture, ALMOS-MK uses generic ''device descriptors'' (implemented by the ''device_t'' structure). For multi-channels peripherals, ALMOS-MK defines one ''device descriptor'' per channel. This descriptor contains the functional index, the implementation index, the channel index, and the physical base address of the segment containing the addressable registers for this peripheral channel. 24 24 25 Each device descriptor contains a waiting queue of pending commands registered by the various client sthreads.25 Each device descriptor contains a waiting queue of pending commands registered by the various client threads. 26 26 27 27 For each generic device type, the device specific API defines the list of available commands, and the specific structure defining the command descriptor (containing the command type and arguments). This structure is embedded (as an union of the various device types) in the thread descriptor, to be passed to the hardware specific driver. 28 28 29 The set of supported generic devices, and the associated APIs are defined below:29 The set of supported generic devices, and their associated APIs are defined below: 30 30 31 || device || type || usage || api definition||32 || IOC || ext || block device controller 33 || TXT || ext || text terminal controller 31 || device || type || usage || api definition || 32 || IOC || ext || block device controller || [wiki:ioc_device_api ioc_api] || 33 || TXT || ext || text terminal controller || [wiki:txt_device_api txt_api] || 34 34 || NIC || ext || network interface controller || [wiki:nic_device_api nic_api] || 35 35 36 36 == C) Devices Descriptors Placement == 37 37 38 '''Internal peripherals''' are replicated in all clusters. In each cluster, the device descriptor is evidently stored in the same cluster as the hardware device itself. These device descriptors are mostly accessed by the local kernel instance, but can also be accessed by threads running in another cluster (it is the case for both the ICU and MMC devices).38 '''Internal peripherals''' are replicated in all clusters. In each cluster, the device descriptor is obviously stored in the same cluster as the hardware device itself. These device descriptors are mostly accessed by the local kernel instance, but can also be accessed by threads running in another cluster (it is the case for both the ICU and MMC devices). 39 39 40 '''External peripherals''' are shared resources, located in the I/O cluster. To minimize contention, the corresponding device descriptors are distributed on all clusters, as uniformly as possible. Therefore, an I/O operation involve generally three clusters: the client cluster, the I/O cluster containing the external peripheral, and the server cluster containing the device descriptor.40 '''External peripherals''' are shared resources, located in the I/O cluster. To minimize contention, the corresponding device descriptors are distributed on all clusters, as uniformly as possible. Therefore, an I/O operation involves generally three clusters: the client cluster, the I/O cluster containing the external peripheral, and the server cluster containing the device descriptor. 41 41 42 42 The ''devices_directory_t'' structure contains extended pointers on all generic devices descriptors defined in the manycore architecture. … … 45 45 * There is one entry per cluster for each '''internal peripheral''', and the corresponding array is indexed by the cluster index (it is not indexed by the cluster identifier cxy, because cxy is not a continuous index). 46 46 47 This device directory beingimplemented as a global variable, is replicated in all clusters, and is initialized in the kernel initialization phase.47 This device directory, implemented as a global variable, is replicated in all clusters, and is initialized in the kernel initialization phase. 48 48 49 49 == D) Waiting queue Management == 50 50 51 The commands waiting queue is implemented as a distributed XLIST, rooted in the device descriptor. To launch an I/O operation, a client thread, running in any cluster, call a function of the device API. This function builds the command descriptor embedded in the thread descriptor, and registers the thread in the waiting queue.51 The commands waiting queue is implemented as a distributed XLIST, rooted in the device descriptor. To launch an I/O operation, a client thread, running in any cluster, calls a function of the device API. This function builds the command descriptor embedded in the thread descriptor, and registers the thread in the waiting queue. 52 52 53 For all I/O operations, ALMOS-MK implements a blocking policy: The thread calling a command function is blocked on the THREAD_BLOCKED_IO condition, and deschedule. It will be re-activated by the driver ISR (Interrupt Service Routine) signaling the completion of the I/O operation.53 For all I/O operations, ALMOS-MK implements a blocking policy: the thread calling a command function is blocked on the THREAD_BLOCKED_IO condition, and descheduled. It will be re-activated by the driver ISR (Interrupt Service Routine) signaling the completion of the I/O operation. 54 54 55 55 The waiting queue is handled as a Multi-Writers / Single-Reader FIFO, protected by a remote_lock. The N writers are the clients threads, whose number is not bounded. 56 The single reader is a server thread associated to the device descriptor, and created at kernel initialization. This thread is in charge of consuming the pending commands from the waiting queue. When the queue is empty, the server thread blocks on the THREAD_BLOCKED_QUEUE condition, and deschedule. It is activated by the client thread when a new command is registered in the queue.56 The single reader is a server thread associated to the device descriptor, and created at kernel initialization. This thread is in charge of consuming the pending commands from the waiting queue. When the queue is empty, the server thread blocks on the THREAD_BLOCKED_QUEUE condition, and is descheduled. It is activated by the client thread when a new command is registered in the queue. 57 57 58 58 Finally, each generic device descriptor contains a link to the specific driver associated to the available hardware implementation. This link is established in the kernel initialization phase. … … 60 60 == E) Drivers API == 61 61 62 To start an I/O operation the server thread associated to the device must call the specific driver corresponding to the hardware peripheral available in the manycore architecture.62 To start an I/O operation, the server thread associated to the device must call the specific driver corresponding to the hardware peripheral available in the manycore architecture. 63 63 64 64 To signal the completion of a given I/O operation, the peripheral rises an IRQ to execute a specific ISR (Interrupt Service Routine) in the client cluster, on the core running the client thread. This requires to dynamically route the IRQ to this core. … … 68 68 '''driver_init()''' 69 69 70 This function sinitialises both the peripheral hardware registers, and the specific global variables defined by a given hardware implementation. It is called in the kernel initialization phase.70 This function initialises both the peripheral hardware registers, and the specific global variables defined by a given hardware implementation. It is called in the kernel initialization phase. 71 71 72 72 '''driver_cmd( xptr_t thread , device_t * device ) 73 73 74 This function is called by the server thread. It access to the peripheral hardware registers to start the I/O operation. Depending on the hardware peripheral implementation,can be blocking or non-blocking for the server thread.74 This function is called by the server thread. It accesses to the peripheral hardware registers to start the I/O operation. Depending on the hardware peripheral implementation, it can be blocking or non-blocking for the server thread. 75 75 * It is blocking on the THREAD_BLOCKED_DEV_ISR condition, if the hardware peripheral supports only one simultaneous I/O operation. Examples are a simple disk controller, or a text terminal controller. The blocked server thread must be re-activated by the ISR signaling completion of the current I/O operation. 76 76 * It is non-blocking if the hardware peripheral supports several simultaneous I/O operations. Example is an AHCI compliant disk controller. It blocks only if the number of simultaneous I/O operations becomes larger than the max number of concurrent operations supported by the hardware. … … 80 80 '''driver_isr( xptr_t device )''' 81 81 82 This function is executed in the client cluster, on the core running the client thread. It access the peripheral hardware registerto get the I/O operation error status, acknowledge the IRQ, and unblock the client thread.83 If the server thread has been blocked, it unblock alsothe server thread.82 This function is executed in the client cluster, on the core running the client thread. It accesses the peripheral hardware registers to get the I/O operation error status, acknowledge the IRQ, and unblock the client thread. 83 If the server thread has been blocked, it also unblocks the server thread. 84 84 The ''device'' argument is the extended pointer on the device descriptor. 85 85 86 86 == F) Implementation == 87 87 88 It is worth to note that thisgeneral I/O operation mechanism involves generally three clusters (client cluster / server cluster / IO cluster), but does not use any RPC:89 * to post a new command in the waiting queue of a given (remote) device descriptor, the client thread uses only few remote access to be registered in the distributed XLIST rooted in the server cluster.90 * to launch the I/O operation on the (remote) peripheral, the server thread uses only remote access to the physical registers located in the I/O cluster.91 * To complete the I/O operation, the ISR running on the client cluster access peripheral registers in I/O clusters, reports I/O operation status in the command descriptor, and unblock client thread and server thread, using only local or remote accesses.88 It is worth noting that this general I/O operation mechanism involves generally three clusters (client cluster / server cluster / IO cluster), but does not use any RPC: 89 * To post a new command in the waiting queue of a given (remote) device descriptor, the client thread uses only few remote accesses to be registered in the distributed XLIST rooted in the server cluster. 90 * To launch the I/O operation on the (remote) peripheral, the server thread uses only remote accesses to the physical registers located in the I/O cluster. 91 * To complete the I/O operation, the ISR running on the client cluster accesses peripheral registers in the I/O cluster, reports the I/O operation status in the command descriptor, and unblocks the client and server threads, using only local or remote accesses.