- kdevelop3 project files
[lightOS.git] / kernel / id.cpp
blob48c23df6c4cefdc5311f5428f8101dd2598a8e82
1 /*
2 lightOS kernel
3 Copyright (C) 2006-2009 Jörg Pfähler
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <kernel/id.hpp>
20 #include <kernel/spinlock.hpp>
21 #include <lightOS/lightOS.hpp>
22 using namespace kernel;
24 libkernel::port_id_t lastPortId = libkernel::message_port::user;
25 libkernel::shared_memory_id_t lastSharedMemoryId = 0;
26 #ifdef _LIGHTOS_SMP
27 lightOS::spinlock mIdLock;
28 #endif
30 id kernel::generateId()
32 LOCK(mIdLock);
33 id Id = ++lastPortId;
34 UNLOCK(mIdLock);
35 return Id;
37 libkernel::port_id_t kernel::generatePortId()
39 LOCK(mIdLock);
40 libkernel::port_id_t Id = ++lastPortId;
41 UNLOCK(mIdLock);
42 return Id;
44 libkernel::shared_memory_id_t kernel::generateSharedMemoryId()
46 LOCK(mIdLock);
47 libkernel::shared_memory_id_t Id = ++lastSharedMemoryId;
48 UNLOCK(mIdLock);
49 return Id;