OsdSynch.c (4fa8ded9c51fbea0c7c4601f68e4b8df5450e9d5) | OsdSynch.c (9d839ea8e4a9327a06de07eb9427eec4357a93e3) |
---|---|
1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 122 unchanged lines hidden (view full) --- 131 if (tmo <= 0) 132 tmo = 1; 133 } 134 135 mtx_lock(&as->as_mtx); 136 DEBUG_PRINT(TRACE_MUTEX, ("get %d units from semaphore %p (has %d), timeout %d\n", 137 Units, as, as->as_units, Timeout)); 138 for (;;) { | 1/*- 2 * Copyright (c) 2000 Michael Smith 3 * Copyright (c) 2000 BSDi 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 122 unchanged lines hidden (view full) --- 131 if (tmo <= 0) 132 tmo = 1; 133 } 134 135 mtx_lock(&as->as_mtx); 136 DEBUG_PRINT(TRACE_MUTEX, ("get %d units from semaphore %p (has %d), timeout %d\n", 137 Units, as, as->as_units, Timeout)); 138 for (;;) { |
139 if (as->as_inits == ACPI_NO_UNIT_LIMIT) { 140 result = AE_OK; 141 break; 142 } |
|
139 if (as->as_units >= Units) { 140 as->as_units -= Units; 141 result = AE_OK; 142 break; 143 } 144 if (Timeout < 0) { 145 result = AE_TIME; 146 break; --- 25 unchanged lines hidden (view full) --- 172 FUNCTION_TRACE(__func__); 173 174 if (as == NULL) 175 return_ACPI_STATUS(AE_BAD_PARAMETER); 176 177 mtx_lock(&as->as_mtx); 178 DEBUG_PRINT(TRACE_MUTEX, ("return %d units to semaphore %p (has %d)\n", 179 Units, as, as->as_units)); | 143 if (as->as_units >= Units) { 144 as->as_units -= Units; 145 result = AE_OK; 146 break; 147 } 148 if (Timeout < 0) { 149 result = AE_TIME; 150 break; --- 25 unchanged lines hidden (view full) --- 176 FUNCTION_TRACE(__func__); 177 178 if (as == NULL) 179 return_ACPI_STATUS(AE_BAD_PARAMETER); 180 181 mtx_lock(&as->as_mtx); 182 DEBUG_PRINT(TRACE_MUTEX, ("return %d units to semaphore %p (has %d)\n", 183 Units, as, as->as_units)); |
180 as->as_units += Units; 181 if (as->as_units > as->as_maxunits) 182 as->as_units = as->as_maxunits; | 184 if (as->as_units != ACPI_NO_UNIT_LIMIT) { 185 as->as_units += Units; 186 if (as->as_units > as->as_maxunits) 187 as->as_units = as->as_maxunits; 188 } |
183 wakeup(as); 184 mtx_unlock(&as->as_mtx); 185 return_ACPI_STATUS(AE_OK); 186#else 187 return(AE_OK); 188#endif 189} | 189 wakeup(as); 190 mtx_unlock(&as->as_mtx); 191 return_ACPI_STATUS(AE_OK); 192#else 193 return(AE_OK); 194#endif 195} |