mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-08-03 17:26:08 -04:00
Review naming
This commit is contained in:
parent
6eb0a44a74
commit
7e7f82793b
@ -19,14 +19,14 @@ struct int_lock {
|
||||
/*!
|
||||
* \brief Acquire the lock. This will disable preemption.
|
||||
*/
|
||||
void acquire(){
|
||||
void lock(){
|
||||
arch::disable_hwint(rflags);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Release the lock. This will enable preemption.
|
||||
*/
|
||||
void release(){
|
||||
void unlock(){
|
||||
arch::enable_hwint(rflags);
|
||||
}
|
||||
|
||||
@ -45,14 +45,14 @@ struct direct_int_lock {
|
||||
* \brief Construct a new direct_int_lock and acquire the lock.
|
||||
*/
|
||||
direct_int_lock(){
|
||||
lock.acquire();
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Destruct a direct_int_lock and release the lock.
|
||||
*/
|
||||
~direct_int_lock(){
|
||||
lock.release();
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -38,19 +38,19 @@ struct mutex {
|
||||
/*!
|
||||
* \brief Acquire the lock
|
||||
*/
|
||||
void acquire(){
|
||||
lock.acquire();
|
||||
void lock(){
|
||||
value_lock.lock();
|
||||
|
||||
if(value > 0){
|
||||
value = 0;
|
||||
|
||||
lock.release();
|
||||
value_lock.unlock();
|
||||
} else {
|
||||
auto pid = scheduler::get_pid();
|
||||
queue.push(pid);
|
||||
|
||||
scheduler::block_process_light(pid);
|
||||
lock.release();
|
||||
value_lock.unlock();
|
||||
scheduler::reschedule();
|
||||
}
|
||||
}
|
||||
@ -58,8 +58,8 @@ struct mutex {
|
||||
/*!
|
||||
* \brief Acquire the lock
|
||||
*/
|
||||
void release(){
|
||||
std::lock_guard<spinlock> l(lock);
|
||||
void unlock(){
|
||||
std::lock_guard<spinlock> l(value_lock);
|
||||
|
||||
if(queue.empty()){
|
||||
value = 1;
|
||||
@ -73,7 +73,7 @@ struct mutex {
|
||||
}
|
||||
|
||||
private:
|
||||
mutable spinlock lock; ///< The spin protecting the value
|
||||
mutable spinlock value_lock; ///< The spin protecting the value
|
||||
volatile size_t value; ///< The value of the mutex
|
||||
circular_buffer<scheduler::pid_t, 16> queue; ///< The sleep queue
|
||||
};
|
||||
|
@ -34,18 +34,18 @@ struct semaphore {
|
||||
* This will effectively decrease the current counter by 1 once the critical
|
||||
* section is entered.
|
||||
*/
|
||||
void acquire(){
|
||||
lock.acquire();
|
||||
void lock(){
|
||||
value_lock.lock();
|
||||
|
||||
if(value > 0){
|
||||
--value;
|
||||
lock.release();
|
||||
value_lock.unlock();
|
||||
} else {
|
||||
auto pid = scheduler::get_pid();
|
||||
queue.push(pid);
|
||||
|
||||
scheduler::block_process_light(pid);
|
||||
lock.release();
|
||||
value_lock.unlock();
|
||||
scheduler::reschedule();
|
||||
}
|
||||
}
|
||||
@ -56,8 +56,8 @@ struct semaphore {
|
||||
* This will effectively increase the current counter by 1 once the critical
|
||||
* section is left.
|
||||
*/
|
||||
void release(){
|
||||
std::lock_guard<spinlock> l(lock);
|
||||
void unlock(){
|
||||
std::lock_guard<spinlock> l(value_lock);
|
||||
|
||||
if(queue.empty()){
|
||||
++value;
|
||||
@ -78,7 +78,7 @@ struct semaphore {
|
||||
* section is left.
|
||||
*/
|
||||
void release(size_t n){
|
||||
std::lock_guard<spinlock> l(lock);
|
||||
std::lock_guard<spinlock> l(value_lock);
|
||||
|
||||
if(queue.empty()){
|
||||
value += n;
|
||||
@ -96,7 +96,7 @@ struct semaphore {
|
||||
}
|
||||
|
||||
private:
|
||||
mutable spinlock lock; ///< The spin lock protecting the counter
|
||||
mutable spinlock value_lock; ///< The spin lock protecting the counter
|
||||
volatile size_t value; ///< The value of the counter
|
||||
circular_buffer<scheduler::pid_t, 16> queue; ///< The sleep queue
|
||||
};
|
||||
|
@ -19,8 +19,8 @@ struct spinlock {
|
||||
*
|
||||
* This will wait indefinitely.
|
||||
*/
|
||||
void acquire(){
|
||||
while(!__sync_bool_compare_and_swap(&lock, 0, 1));
|
||||
void lock(){
|
||||
while(!__sync_bool_compare_and_swap(&value, 0, 1));
|
||||
__sync_synchronize();
|
||||
//TODO The last synchronize is probably not necessary
|
||||
}
|
||||
@ -28,13 +28,13 @@ struct spinlock {
|
||||
/*!
|
||||
* \brief Release the lock
|
||||
*/
|
||||
void release(){
|
||||
void unlock(){
|
||||
__sync_synchronize();
|
||||
lock = 0;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
volatile size_t lock = 0; ///< The value of the lock
|
||||
volatile size_t value = 0; ///< The value of the lock
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -52,7 +52,7 @@ struct interface_descriptor {
|
||||
void send(ethernet::packet& p){
|
||||
std::lock_guard<mutex> l(tx_lock);
|
||||
tx_queue.push(p);
|
||||
tx_sem.release();
|
||||
tx_sem.unlock();
|
||||
}
|
||||
|
||||
bool is_loopback() const {
|
||||
|
@ -70,7 +70,7 @@ void condition_variable::wake_up_all() {
|
||||
}
|
||||
|
||||
void condition_variable::sleep() {
|
||||
lock.acquire();
|
||||
lock.lock();
|
||||
|
||||
//Get the current process information
|
||||
auto pid = scheduler::get_pid();
|
||||
@ -85,7 +85,7 @@ void condition_variable::sleep() {
|
||||
//This process will sleep
|
||||
scheduler::block_process_light(pid);
|
||||
|
||||
lock.release();
|
||||
lock.unlock();
|
||||
|
||||
scheduler::reschedule();
|
||||
}
|
||||
@ -95,7 +95,7 @@ bool condition_variable::sleep(size_t ms) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lock.acquire();
|
||||
lock.lock();
|
||||
|
||||
//Get the current process information
|
||||
auto pid = scheduler::get_pid();
|
||||
@ -110,12 +110,12 @@ bool condition_variable::sleep(size_t ms) {
|
||||
//This process will sleep
|
||||
scheduler::block_process_timeout_light(pid, ms);
|
||||
|
||||
lock.release();
|
||||
lock.unlock();
|
||||
|
||||
scheduler::reschedule();
|
||||
|
||||
// At this point we need the lock again to check the queue
|
||||
lock.acquire();
|
||||
lock.lock();
|
||||
|
||||
bool obtained = true;
|
||||
|
||||
@ -137,7 +137,7 @@ bool condition_variable::sleep(size_t ms) {
|
||||
}
|
||||
|
||||
// Final release of the lock
|
||||
lock.release();
|
||||
lock.unlock();
|
||||
|
||||
return obtained;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ volatile bool secondary_invoked = false;
|
||||
|
||||
void primary_controller_handler(interrupt::syscall_regs*, void*){
|
||||
if(scheduler::is_started()){
|
||||
primary_lock.release();
|
||||
primary_lock.unlock();
|
||||
} else {
|
||||
primary_invoked = true;
|
||||
}
|
||||
@ -48,7 +48,7 @@ void primary_controller_handler(interrupt::syscall_regs*, void*){
|
||||
|
||||
void secondary_controller_handler(interrupt::syscall_regs*, void*){
|
||||
if(scheduler::is_started()){
|
||||
secondary_lock.release();
|
||||
secondary_lock.unlock();
|
||||
} else {
|
||||
secondary_invoked = true;
|
||||
}
|
||||
@ -56,7 +56,7 @@ void secondary_controller_handler(interrupt::syscall_regs*, void*){
|
||||
|
||||
void ata_wait_irq_primary(){
|
||||
if(scheduler::is_started()){
|
||||
primary_lock.acquire();
|
||||
primary_lock.lock();
|
||||
} else {
|
||||
while(!primary_invoked){
|
||||
asm volatile ("nop");
|
||||
@ -72,7 +72,7 @@ void ata_wait_irq_primary(){
|
||||
|
||||
void ata_wait_irq_secondary(){
|
||||
if(scheduler::is_started()){
|
||||
secondary_lock.acquire();
|
||||
secondary_lock.lock();
|
||||
} else {
|
||||
while(!secondary_invoked){
|
||||
asm volatile ("nop");
|
||||
|
@ -30,7 +30,7 @@ void send_packet(network::interface_descriptor& interface, network::ethernet::pa
|
||||
std::copy_n(packet.payload, packet.payload_size, packet_buffer);
|
||||
|
||||
interface.rx_queue.emplace_push(packet_buffer, packet.payload_size);
|
||||
interface.rx_sem.release();
|
||||
interface.rx_sem.unlock();
|
||||
|
||||
logging::logf(logging::log_level::TRACE, "loopback: Packet transmitted correctly\n");
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ void packet_handler(interrupt::syscall_regs*, void* data){
|
||||
direct_int_lock lock;
|
||||
|
||||
interface.rx_queue.push(packet);
|
||||
interface.rx_sem.release();
|
||||
interface.rx_sem.unlock();
|
||||
}
|
||||
|
||||
cur_rx = (cur_rx + packet_length + 4 + 3) & ~3; //align on 4 bytes
|
||||
@ -198,7 +198,7 @@ void send_packet(network::interface_descriptor& interface, network::ethernet::pa
|
||||
direct_int_lock lock;
|
||||
|
||||
interface.rx_queue.emplace_push(packet_buffer, packet.payload_size);
|
||||
interface.rx_sem.release();
|
||||
interface.rx_sem.unlock();
|
||||
|
||||
logging::logf(logging::log_level::TRACE, "rtl8139: Packet to self transmitted correctly\n");
|
||||
|
||||
@ -209,7 +209,7 @@ void send_packet(network::interface_descriptor& interface, network::ethernet::pa
|
||||
auto iobase = desc.iobase;
|
||||
|
||||
// Wait for a free entry in the tx buffers
|
||||
desc.tx_sem.acquire();
|
||||
desc.tx_sem.lock();
|
||||
|
||||
// Claim an entry in the tx buffers
|
||||
auto entry = __sync_fetch_and_add(&desc.cur_tx, 1) % tx_buffers;
|
||||
|
@ -186,7 +186,7 @@ void fat32::fat32_file_system::init(){
|
||||
std::unique_ptr<fat_bs_t> fat_bs_tmp(new fat_bs_t());
|
||||
|
||||
if(read_sectors(0, 1, fat_bs_tmp.get())){
|
||||
fat_bs = fat_bs_tmp.release();
|
||||
fat_bs = fat_bs_tmp.unlock();
|
||||
|
||||
//TODO fat_bs->signature should be 0xAA55
|
||||
//TODO fat_bs->file_system_type should be FAT32
|
||||
@ -199,7 +199,7 @@ void fat32::fat32_file_system::init(){
|
||||
std::unique_ptr<fat_is_t> fat_is_tmp(new fat_is_t());
|
||||
|
||||
if(read_sectors(fs_information_sector, 1, fat_is_tmp.get())){
|
||||
fat_is = fat_is_tmp.release();
|
||||
fat_is = fat_is_tmp.unlock();
|
||||
|
||||
//TODO fat_is->signature_start should be 0x52 0x52 0x61 0x41
|
||||
//TODO fat_is->signature_middle should be 0x72 0x72 0x41 0x61
|
||||
|
@ -45,7 +45,7 @@ void rx_thread(void* data){
|
||||
logging::logf(logging::log_level::TRACE, "network: RX Thread for interface %u started (pid:%u)\n", interface.id, pid);
|
||||
|
||||
while(true){
|
||||
interface.rx_sem.acquire();
|
||||
interface.rx_sem.lock();
|
||||
|
||||
auto packet = interface.rx_queue.pop();
|
||||
network::ethernet::decode(interface, packet);
|
||||
@ -63,7 +63,7 @@ void tx_thread(void* data){
|
||||
logging::logf(logging::log_level::TRACE, "network: TX Thread for interface %u started (pid:%u)\n", interface.id, pid);
|
||||
|
||||
while(true){
|
||||
interface.tx_sem.acquire();
|
||||
interface.tx_sem.lock();
|
||||
|
||||
auto packet = interface.tx_queue.pop();
|
||||
interface.hw_send(interface, packet);
|
||||
|
@ -306,7 +306,7 @@ void AcpiOsDeleteMutex(ACPI_MUTEX handle){
|
||||
ACPI_STATUS AcpiOsAcquireMutex(ACPI_MUTEX handle, UINT16 Timeout){
|
||||
auto* lock = static_cast<mutex<false>*>(handle);
|
||||
|
||||
lock->acquire();
|
||||
lock->lock();
|
||||
|
||||
return AE_OK;
|
||||
}
|
||||
@ -317,7 +317,7 @@ ACPI_STATUS AcpiOsAcquireMutex(ACPI_MUTEX handle, UINT16 Timeout){
|
||||
void AcpiOsReleaseMutex(ACPI_MUTEX handle){
|
||||
auto* lock = static_cast<mutex<false>*>(handle);
|
||||
|
||||
lock->release();
|
||||
lock->unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -353,7 +353,7 @@ ACPI_STATUS AcpiOsWaitSemaphore(ACPI_SEMAPHORE handle, UINT32 units, UINT16 /*ti
|
||||
auto* lock = static_cast<semaphore*>(handle);
|
||||
|
||||
for(size_t i = 0; i < units; ++i){
|
||||
lock->acquire();
|
||||
lock->lock();
|
||||
}
|
||||
|
||||
return AE_OK;
|
||||
@ -396,7 +396,7 @@ void AcpiOsDeleteLock(ACPI_HANDLE handle){
|
||||
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK handle){
|
||||
auto* lock = static_cast<int_lock*>(handle);
|
||||
|
||||
lock->acquire();
|
||||
lock->lock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -407,7 +407,7 @@ ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK handle){
|
||||
void AcpiOsReleaseLock(ACPI_SPINLOCK handle, ACPI_CPU_FLAGS /*flags*/){
|
||||
auto* lock = static_cast<int_lock*>(handle);
|
||||
|
||||
lock->release();
|
||||
lock->unlock();
|
||||
}
|
||||
|
||||
// Input / Output
|
||||
|
@ -77,13 +77,13 @@ public:
|
||||
array = new T[s];
|
||||
}
|
||||
|
||||
unique_heap_array(unique_heap_array&& u) : array(u.release()), _size(u._size) {
|
||||
unique_heap_array(unique_heap_array&& u) : array(u.unlock()), _size(u._size) {
|
||||
u._size = 0;
|
||||
}
|
||||
|
||||
unique_heap_array& operator=(unique_heap_array&& u){
|
||||
_size = u._size;
|
||||
reset(u.release());
|
||||
reset(u.unlock());
|
||||
u._size = 0;
|
||||
return *this;
|
||||
}
|
||||
@ -113,7 +113,7 @@ public:
|
||||
return array;
|
||||
}
|
||||
|
||||
pointer_type release(){
|
||||
pointer_type unlock(){
|
||||
pointer_type p = array;
|
||||
array = nullptr;
|
||||
return p;
|
||||
|
@ -15,7 +15,7 @@ struct lock_guard {
|
||||
Lock& lock;
|
||||
|
||||
explicit lock_guard(Lock& l) : lock(l) {
|
||||
lock.acquire();
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
lock_guard(const lock_guard&) = delete;
|
||||
@ -25,7 +25,7 @@ struct lock_guard {
|
||||
lock_guard& operator=(const lock_guard&&) = delete;
|
||||
|
||||
~lock_guard(){
|
||||
lock.release();
|
||||
lock.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -56,9 +56,9 @@ public:
|
||||
|
||||
explicit unique_ptr(pointer_type p) : _data(make_tuple(p, deleter_type())) {}
|
||||
|
||||
unique_ptr(unique_ptr&& u) : _data(make_tuple(u.release(), u.get_deleter())) {}
|
||||
unique_ptr(unique_ptr&& u) : _data(make_tuple(u.unlock(), u.get_deleter())) {}
|
||||
unique_ptr& operator=(unique_ptr&& u){
|
||||
reset(u.release());
|
||||
reset(u.unlock());
|
||||
get_deleter() = std::forward<deleter_type>(u.get_deleter());
|
||||
return *this;
|
||||
}
|
||||
@ -102,7 +102,7 @@ public:
|
||||
return get() == pointer_type() ? false : true;
|
||||
}
|
||||
|
||||
pointer_type release(){
|
||||
pointer_type unlock(){
|
||||
pointer_type p = get();
|
||||
std::get<0>(_data) = pointer_type();
|
||||
return p;
|
||||
@ -136,9 +136,9 @@ public:
|
||||
|
||||
explicit unique_ptr(pointer_type p) : _data(make_tuple(p, deleter_type())) {}
|
||||
|
||||
unique_ptr(unique_ptr&& u) : _data(make_tuple(u.release(), u.get_deleter())) {}
|
||||
unique_ptr(unique_ptr&& u) : _data(make_tuple(u.unlock(), u.get_deleter())) {}
|
||||
unique_ptr& operator=(unique_ptr&& u){
|
||||
reset(u.release());
|
||||
reset(u.unlock());
|
||||
get_deleter() = std::forward<deleter_type>(u.get_deleter());
|
||||
return *this;
|
||||
}
|
||||
@ -176,7 +176,7 @@ public:
|
||||
return get() == pointer_type() ? false : true;
|
||||
}
|
||||
|
||||
pointer_type release(){
|
||||
pointer_type unlock(){
|
||||
pointer_type p = get();
|
||||
std::get<0>(_data) = pointer_type();
|
||||
return p;
|
||||
|
Loading…
x
Reference in New Issue
Block a user